Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AMM support #2071

Merged
merged 121 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
25bdb69
update definitions.json
khancode Aug 16, 2022
2680c34
add AMMInstanceCreate
khancode Aug 18, 2022
6bcfc2b
renamed LPTokens to LPToken in definitions.json
khancode Aug 18, 2022
ff60b54
update HISTORY.md
khancode Aug 18, 2022
3461fcc
add amm_info RPC command
khancode Aug 18, 2022
e64a668
add AMMDeposit
khancode Aug 19, 2022
35fef65
use null check for missing fields
khancode Aug 19, 2022
3617487
add AMMWithdraw
khancode Aug 19, 2022
b794f90
add AMMVote
khancode Aug 19, 2022
e79dcb5
fix lint error
khancode Aug 19, 2022
db6d32f
add max trading fee check to AMMVote
khancode Aug 20, 2022
78e0a86
refactor MAX_TRADING_FEE to be in one place
khancode Aug 20, 2022
7a035af
add AMMBid
khancode Aug 20, 2022
4b18f06
add AuthAccount interface to AMMBid
khancode Aug 20, 2022
835dc67
refactor tests
khancode Aug 20, 2022
c95f8af
add AMMID to AMMInfoResponse
khancode Aug 28, 2022
b8e4f24
update amm_info docstrings
khancode Aug 30, 2022
ed7760c
fix EPrice type to be Amount
khancode Aug 30, 2022
0de755b
update EPrice validation error message and add missing tests
khancode Aug 30, 2022
e13b27e
update definitions to fix AMM in LEDGER_ENTRY_TYPES
khancode Aug 30, 2022
2796c2a
add missing test case Asset1In and Asset2In valid
khancode Aug 30, 2022
6150d33
add missing test case Asset1Out and Asset2Out valid
khancode Aug 30, 2022
8ef2483
add negative FeeVal check
khancode Aug 30, 2022
e9778eb
update HISTORY.md to specify XLS-30
khancode Aug 30, 2022
6a06412
update wording on AMMDeposit & AMMWithdraw validation errors
khancode Aug 30, 2022
85b8a39
add negative TradingFee check
khancode Aug 30, 2022
a174d09
fix ammInfo response
khancode Sep 2, 2022
533c8ab
add AMMID as optional param in ammInfo response
khancode Sep 2, 2022
c0e0c15
fix EPrice validation checks in AMMDeposit & AMMWithdraw
khancode Sep 2, 2022
56b70aa
add VoteSlots as optional param in AMMInfoResponse
khancode Sep 5, 2022
aed4353
update VoteEntry interface
khancode Sep 5, 2022
25efafa
Merge branch 'develop' into amm
khancode Sep 13, 2022
220d9fb
fix deposit and withdraw tests
khancode Sep 13, 2022
a80f159
fix AMMBid ValidationError
khancode Sep 15, 2022
a2bce8f
update definitions.json with different AuthAccounts number
khancode Sep 15, 2022
f040378
Merge branch 'main' into amm
khancode Oct 31, 2022
a76aeb2
Change amm_info asset parameters to Currency type
khancode Oct 31, 2022
acdfbd5
API name changes with updated definitions.json
khancode Nov 9, 2022
54b86bc
rename amm_info param asset1 -> asset
khancode Nov 9, 2022
c99aa04
fix typo
khancode Nov 9, 2022
3120abc
change AMM_MAX_TRADING_FEE to 1%
khancode Nov 9, 2022
25752d7
Use Asset/Asset2 instead of AMMID for Deposit/Withdraw/Bid/Vote
khancode Nov 9, 2022
6a67715
Merge branch 'main' into amm
khancode Nov 9, 2022
64d8a90
add Deposit/Withdraw flags
khancode Nov 9, 2022
bcdd8fe
rename FeeVal -> TradingFee in VoteEntry
khancode Nov 9, 2022
eba8bd2
rename MinBidPrice -> BidMin and MaxBidPrice -> BidMax
khancode Nov 9, 2022
1c26e8b
update definitions to change Asset & Asset2 nth values to 3 & 4
khancode Nov 9, 2022
007717a
Merge branch 'main' into amm
khancode Nov 16, 2022
40388cc
update definitions
khancode Nov 16, 2022
0574fab
add Issue type and tests for Asset/Asset2
khancode Nov 17, 2022
64e4242
remove AMMID from amm_info and use Issue type
khancode Nov 17, 2022
e32db9d
update amm_info fields
khancode Nov 17, 2022
ff65441
fix lint errors
khancode Nov 17, 2022
7f2b407
Merge branch 'main' into amm
khancode Nov 17, 2022
434ad71
update unit tests
khancode Nov 17, 2022
0970753
add AMM codec-fixtures
khancode Nov 17, 2022
feafc0c
update Issue type
khancode Nov 17, 2022
98f8223
add one asset and withdraw all tests
khancode Nov 17, 2022
2bb4d77
Merge branch 'main' into amm
khancode Dec 15, 2022
ec1d8b6
refactor amm_info response fields to match AMMDevnet
khancode Dec 15, 2022
218ca00
update definitions.json with refactored error codes
khancode Jan 9, 2023
e634db3
update ammInfo.ts response model
khancode Jan 9, 2023
f61cf02
Merge branch 'main' into amm
khancode Jan 9, 2023
f3d6bd4
remove invalid fields from ammInfo.ts response model
khancode Jan 9, 2023
8cdeb2b
update time_interval description
khancode Jan 9, 2023
88b8211
Merge branch 'main' into amm
khancode Feb 15, 2023
287dc1a
rename test model names and fix lint errors
khancode Feb 15, 2023
7e84277
add Owner Reserve Fee for AMMCreate transaction
khancode Feb 15, 2023
d2f7fe6
add missing asset_frozen field
khancode Feb 15, 2023
df75b4a
replace Issue with IssuedCurrency
khancode Feb 16, 2023
d495903
Merge branch 'main' into amm
khancode Feb 16, 2023
651780f
refactor: convert flags to number
khancode Feb 16, 2023
d43fd78
update asset pair to use Currency type
khancode Feb 21, 2023
5c7e315
Merge branch 'main' into amm
khancode Feb 22, 2023
f9f2107
refactor isIssue to isCurrency
khancode Feb 23, 2023
bad598f
add AMM ledger entry object, lsfAMM flag, amm fields to LedgerEntryRe…
khancode May 16, 2023
94bb54a
Merge branch 'main' into amm
khancode May 16, 2023
aa37dfe
update definitions.json
khancode May 16, 2023
30b4406
Merge branch 'main' into amm
khancode May 23, 2023
a2f5b57
WIP defintions
khancode May 23, 2023
b80a196
Merge branch 'main' into amm
khancode May 23, 2023
8c34754
update codec-fixtures
khancode May 23, 2023
70609e0
fix definitions test
khancode May 24, 2023
5324829
Merge branch 'main' into amm
khancode May 24, 2023
85bc5b7
Merge branch 'main' into amm
khancode May 25, 2023
5a38651
Merge branch 'main' into amm
khancode May 31, 2023
b289350
Merge branch 'main' into amm
khancode Jun 2, 2023
426aefb
Merge branch 'main' into amm
khancode Jun 4, 2023
7664b62
update DiscountedFee definition
khancode Jun 6, 2023
143f860
update definitions
khancode Jun 7, 2023
f8eb832
update codec-fixtures
khancode Jun 7, 2023
f52ea8e
Merge branch 'main' into amm
khancode Jun 9, 2023
d7c4361
update definitions
khancode Jun 9, 2023
c1ee18e
Merge branch 'main' into amm
khancode Jun 9, 2023
be76ffd
Merge branch 'main' into amm
khancode Jul 10, 2023
2287313
Merge branch 'main' into amm
ckniffen Jul 17, 2023
e1fcc99
update unit tests
khancode Jul 17, 2023
41e0ee9
update amm_info response
khancode Jul 17, 2023
41ca08f
sort imports/exports
khancode Jul 17, 2023
8cb4a1e
update jsdoc
khancode Jul 17, 2023
1a9e842
update amm_info jsdoc
khancode Jul 17, 2023
08bd26a
Merge branch 'main' into amm
khancode Jul 17, 2023
a28198c
update jsdoc
khancode Jul 17, 2023
a3070db
Merge branch 'main' into amm
khancode Jul 25, 2023
5878433
convert caution to all caps
khancode Jul 25, 2023
34b667d
add validation for AuthAccounts
khancode Jul 27, 2023
70d180c
refactor and export interfaces
khancode Jul 27, 2023
2f5b634
use Currency type
khancode Aug 1, 2023
17e7e86
Merge branch 'main' into amm
khancode Aug 7, 2023
a7b3cf4
Merge branch 'main' into amm
khancode Aug 8, 2023
29e5348
update definitions
khancode Aug 8, 2023
b5a8b73
add AMMDelete
khancode Aug 8, 2023
32e431e
Merge branch 'main' into amm
khancode Aug 12, 2023
5e098f1
Merge branch 'main' into amm
khancode Aug 16, 2023
440ef57
rename Issue to Currency in error message
khancode Aug 16, 2023
434754c
mark asset frozen as optional fields
khancode Aug 16, 2023
bffce20
refactor isAuthAccounts
khancode Aug 16, 2023
760eb9a
add AMMDelete jsdoc
khancode Aug 16, 2023
1e00753
rename to validateAuthAccounts
khancode Aug 17, 2023
14f6829
fix typo
khancode Aug 17, 2023
e463631
fix typo in unit test
khancode Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
250 changes: 249 additions & 1 deletion packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"UInt192": 21,
"UInt384": 22,
"UInt512": 23,
"Issue": 24,
"Transaction": 10001,
"LedgerEntry": 10002,
"Validation": 10003,
Expand All @@ -44,6 +45,7 @@
"NegativeUNL": 78,
"NFTokenPage": 80,
"NFTokenOffer": 55,
"AMM": 121,
"Any": -3,
"Child": -2,
"Nickname": 110,
Expand Down Expand Up @@ -271,6 +273,26 @@
"type": "UInt16"
}
],
[
"TradingFee",
{
"nth": 5,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt16"
}
],
[
"DiscountedFee",
{
"nth": 6,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt16"
}
],
[
"Version",
{
Expand Down Expand Up @@ -771,6 +793,26 @@
"type": "UInt32"
}
],
[
"VoteWeight",
{
"nth": 48,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"FirstNFTokenSequence",
{
"nth": 50,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"IndexNext",
{
Expand Down Expand Up @@ -1121,6 +1163,16 @@
"type": "Hash256"
}
],
[
"AMMID",
{
"nth": 14,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Hash256"
}
],
[
"BookDirectory",
{
Expand Down Expand Up @@ -1391,6 +1443,36 @@
"type": "Amount"
}
],
[
"Amount2",
JST5000 marked this conversation as resolved.
Show resolved Hide resolved
{
"nth": 11,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"BidMin",
{
"nth": 12,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"BidMax",
{
"nth": 13,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"MinimumOffer",
{
Expand Down Expand Up @@ -1431,6 +1513,86 @@
"type": "Amount"
}
],
[
"BaseFeeDrops",
{
"nth": 22,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"ReserveBaseDrops",
{
"nth": 23,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"ReserveIncrementDrops",
{
"nth": 24,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"LPTokenOut",
{
"nth": 25,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"LPTokenIn",
{
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"EPrice",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"Price",
{
"nth": 28,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"LPTokenBalance",
{
"nth": 31,
JST5000 marked this conversation as resolved.
Show resolved Hide resolved
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"PublicKey",
{
Expand Down Expand Up @@ -1821,6 +1983,26 @@
"type": "PathSet"
}
],
[
"Asset",
{
"nth": 3,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Issue"
}
],
[
"Asset2",
{
"nth": 4,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Issue"
}
],
[
"TransactionMetaData",
{
Expand Down Expand Up @@ -2031,6 +2213,36 @@
"type": "STObject"
}
],
[
"VoteEntry",
{
"nth": 25,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"AuctionSlot",
{
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"AuthAccount",
{
"nth": 27,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"Signers",
{
Expand Down Expand Up @@ -2121,6 +2333,16 @@
"type": "STArray"
}
],
[
"VoteSlots",
{
"nth": 12,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"Majorities",
{
Expand Down Expand Up @@ -2170,6 +2392,16 @@
"isSigningField": true,
"type": "STArray"
}
],
[
"AuthAccounts",
{
"nth": 25,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
]
],
"TRANSACTION_RESULTS": {
Expand Down Expand Up @@ -2228,6 +2460,7 @@
"temUNKNOWN": -264,
"temSEQ_AND_TICKET": -263,
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
"temBAD_AMM_TOKENS": -261,

"tefFAILURE": -199,
"tefALREADY": -198,
Expand Down Expand Up @@ -2263,6 +2496,7 @@
"terNO_RIPPLE": -90,
"terQUEUED": -89,
"terPRE_TICKET": -88,
"terNO_AMM": -87,

"tesSUCCESS": 0,

Expand Down Expand Up @@ -2311,7 +2545,15 @@
"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158,
"tecINSUFFICIENT_FUNDS": 159,
"tecOBJECT_NOT_FOUND": 160,
"tecINSUFFICIENT_PAYMENT": 161
"tecINSUFFICIENT_PAYMENT": 161,
"tecUNFUNDED_AMM": 162,
"tecAMM_BALANCE": 163,
"tecAMM_FAILED": 164,
"tecAMM_INVALID_TOKENS": 165,
"tecAMM_EMPTY": 166,
"tecAMM_NOT_EMPTY": 167,
"tecAMM_ACCOUNT": 168,
"tecINCOMPLETE": 169
},
"TRANSACTION_TYPES": {
"Invalid": -1,
Expand Down Expand Up @@ -2344,6 +2586,12 @@
"NFTokenCancelOffer": 28,
"NFTokenAcceptOffer": 29,
"Clawback": 30,
"AMMCreate": 35,
"AMMDeposit": 36,
"AMMWithdraw": 37,
"AMMVote": 38,
"AMMBid": 39,
"AMMDelete": 40,
"EnableAmendment": 100,
"SetFee": 101,
"UNLModify": 102
Expand Down
2 changes: 2 additions & 0 deletions packages/ripple-binary-codec/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Currency } from './currency'
import { Hash128 } from './hash-128'
import { Hash160 } from './hash-160'
import { Hash256 } from './hash-256'
import { Issue } from './issue'
import { PathSet } from './path-set'
import { STArray } from './st-array'
import { STObject } from './st-object'
Expand All @@ -24,6 +25,7 @@ const coreTypes: Record<string, typeof SerializedType> = {
Hash128,
Hash160,
Hash256,
Issue,
PathSet,
STArray,
STObject,
Expand Down
Loading