@typus/typus-perp-sdk 1.1.29 → 1.1.30-codegen
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/sentio.js +604 -538
- package/dist/src/client.d.ts +27 -0
- package/dist/src/client.js +108 -0
- package/dist/src/fetch.d.ts +160 -34
- package/dist/src/fetch.js +365 -665
- package/dist/src/generated/typus_perp/admin.d.ts +117 -0
- package/dist/src/generated/typus_perp/admin.js +110 -0
- package/dist/src/generated/typus_perp/competition.d.ts +22 -0
- package/dist/src/generated/typus_perp/competition.js +58 -0
- package/dist/src/generated/typus_perp/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/typus_perp/deps/std/type_name.js +25 -0
- package/dist/src/generated/typus_perp/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/typus_perp/deps/sui/balance.js +20 -0
- package/dist/src/generated/typus_perp/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_perp/deps/sui/object.js +16 -0
- package/dist/src/generated/typus_perp/deps/sui/object_table.d.ts +19 -0
- package/dist/src/generated/typus_perp/deps/sui/object_table.js +59 -0
- package/dist/src/generated/typus_perp/deps/sui/vec_set.d.ts +18 -0
- package/dist/src/generated/typus_perp/deps/sui/vec_set.js +25 -0
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.d.ts +30 -0
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.js +67 -0
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.d.ts +32 -0
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.js +71 -0
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +23 -0
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.js +61 -0
- package/dist/src/generated/typus_perp/escrow.d.ts +59 -0
- package/dist/src/generated/typus_perp/escrow.js +76 -0
- package/dist/src/generated/typus_perp/lending.d.ts +47 -0
- package/dist/src/generated/typus_perp/lending.js +50 -0
- package/dist/src/generated/typus_perp/lp_pool.d.ts +2327 -0
- package/dist/src/generated/typus_perp/lp_pool.js +1956 -0
- package/dist/src/generated/typus_perp/math.d.ts +95 -0
- package/dist/src/generated/typus_perp/math.js +97 -0
- package/dist/src/generated/typus_perp/position.d.ts +234 -0
- package/dist/src/generated/typus_perp/position.js +204 -0
- package/dist/src/generated/typus_perp/symbol.d.ts +18 -0
- package/dist/src/generated/typus_perp/symbol.js +55 -0
- package/dist/src/generated/typus_perp/tlp.d.ts +13 -0
- package/dist/src/generated/typus_perp/tlp.js +56 -0
- package/dist/src/generated/typus_perp/trading.d.ts +2486 -0
- package/dist/src/generated/typus_perp/trading.js +2476 -0
- package/dist/src/generated/typus_perp/treasury_caps.d.ts +13 -0
- package/dist/src/{_framework/init-loader.js → generated/typus_perp/treasury_caps.js} +17 -10
- package/dist/src/generated/typus_perp/user_account.d.ts +40 -0
- package/dist/src/generated/typus_perp/user_account.js +72 -0
- package/dist/src/generated/typus_stake_pool/admin.d.ts +100 -0
- package/dist/src/generated/typus_stake_pool/admin.js +91 -0
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.js +25 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/object.js +16 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.d.ts +30 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.js +37 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.d.ts +18 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.js +25 -0
- package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +1023 -0
- package/dist/src/generated/typus_stake_pool/stake_pool.js +918 -0
- package/dist/src/generated/utils/index.d.ts +11 -0
- package/dist/src/generated/utils/index.js +135 -0
- package/dist/src/grpc/graphql.d.ts +26 -0
- package/dist/src/grpc/graphql.js +126 -0
- package/dist/src/grpc/grpc.d.ts +1 -0
- package/dist/src/grpc/grpc.js +38 -0
- package/dist/src/grpc/ledgerService.js +64 -0
- package/dist/src/grpc/liveDataService.d.ts +0 -0
- package/dist/src/grpc/liveDataService.js +49 -0
- package/dist/src/index.d.ts +1 -4
- package/dist/src/index.js +21 -39
- package/dist/src/user/history.js +611 -680
- package/dist/src/user/order.d.ts +11 -11
- package/dist/src/user/order.js +171 -302
- package/dist/src/user/orderWithBidReceipt.d.ts +8 -5
- package/dist/src/user/orderWithBidReceipt.js +127 -225
- package/dist/src/user/tlp.d.ts +32 -23
- package/dist/src/user/tlp.js +316 -468
- package/package.json +12 -3
- package/dist/src/_dependencies/source/0x1/ascii/structs.d.ts +0 -92
- package/dist/src/_dependencies/source/0x1/ascii/structs.js +0 -398
- package/dist/src/_dependencies/source/0x1/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x1/index.js +0 -6
- package/dist/src/_dependencies/source/0x1/option/structs.d.ts +0 -52
- package/dist/src/_dependencies/source/0x1/option/structs.js +0 -271
- package/dist/src/_dependencies/source/0x1/string/structs.d.ts +0 -50
- package/dist/src/_dependencies/source/0x1/string/structs.js +0 -256
- package/dist/src/_dependencies/source/0x1/type-name/structs.d.ts +0 -53
- package/dist/src/_dependencies/source/0x1/type-name/structs.js +0 -223
- package/dist/src/_dependencies/source/0x2/bag/structs.d.ts +0 -61
- package/dist/src/_dependencies/source/0x2/bag/structs.js +0 -229
- package/dist/src/_dependencies/source/0x2/balance/structs.d.ts +0 -88
- package/dist/src/_dependencies/source/0x2/balance/structs.js +0 -386
- package/dist/src/_dependencies/source/0x2/coin/structs.d.ts +0 -460
- package/dist/src/_dependencies/source/0x2/coin/structs.js +0 -1247
- package/dist/src/_dependencies/source/0x2/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0x2/index.js +0 -6
- package/dist/src/_dependencies/source/0x2/linked-table/structs.d.ts +0 -153
- package/dist/src/_dependencies/source/0x2/linked-table/structs.js +0 -438
- package/dist/src/_dependencies/source/0x2/object/structs.d.ts +0 -92
- package/dist/src/_dependencies/source/0x2/object/structs.js +0 -364
- package/dist/src/_dependencies/source/0x2/object-table/structs.d.ts +0 -61
- package/dist/src/_dependencies/source/0x2/object-table/structs.js +0 -248
- package/dist/src/_dependencies/source/0x2/sui/structs.d.ts +0 -46
- package/dist/src/_dependencies/source/0x2/sui/structs.js +0 -222
- package/dist/src/_dependencies/source/0x2/table/structs.d.ts +0 -61
- package/dist/src/_dependencies/source/0x2/table/structs.js +0 -248
- package/dist/src/_dependencies/source/0x2/table-vec/structs.d.ts +0 -68
- package/dist/src/_dependencies/source/0x2/table-vec/structs.js +0 -274
- package/dist/src/_dependencies/source/0x2/token/structs.d.ts +0 -449
- package/dist/src/_dependencies/source/0x2/token/structs.js +0 -1095
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.d.ts +0 -370
- package/dist/src/_dependencies/source/0x2/transfer-policy/structs.js +0 -1091
- package/dist/src/_dependencies/source/0x2/url/structs.d.ts +0 -53
- package/dist/src/_dependencies/source/0x2/url/structs.js +0 -223
- package/dist/src/_dependencies/source/0x2/vec-map/structs.d.ts +0 -111
- package/dist/src/_dependencies/source/0x2/vec-map/structs.js +0 -446
- package/dist/src/_dependencies/source/0x2/vec-set/structs.d.ts +0 -51
- package/dist/src/_dependencies/source/0x2/vec-set/structs.js +0 -270
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.d.ts +0 -489
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/airdrop/structs.js +0 -1084
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.d.ts +0 -147
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/big-vector/structs.js +0 -456
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.d.ts +0 -239
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/critbit/structs.js +0 -653
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.d.ts +0 -405
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/ecosystem/structs.js +0 -899
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.d.ts +0 -8
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/index.js +0 -11
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/init.js +0 -102
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/keyed-big-vector/structs.d.ts +0 -227
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/keyed-big-vector/structs.js +0 -632
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.d.ts +0 -699
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/leaderboard/structs.js +0 -1459
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-object-table/structs.d.ts +0 -161
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-object-table/structs.js +0 -438
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.d.ts +0 -147
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/linked-set/structs.js +0 -430
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.d.ts +0 -1071
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tails-staking/structs.js +0 -2261
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.d.ts +0 -279
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/tgld/structs.js +0 -733
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.d.ts +0 -328
- package/dist/src/_dependencies/source/0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a/user/structs.js +0 -892
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.d.ts +0 -88
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/authority/structs.js +0 -263
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.d.ts +0 -347
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/balance-pool/structs.js +0 -591
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.d.ts +0 -73
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/big-vector/structs.js +0 -258
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.d.ts +0 -876
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/dutch/structs.js +0 -1721
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.d.ts +0 -46
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/i64/structs.js +0 -222
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.d.ts +0 -3
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/index.js +0 -6
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/init.js +0 -89
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.d.ts +0 -155
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/linked-list/structs.js +0 -444
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs.d.ts +0 -2386
- package/dist/src/_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs.js +0 -4952
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.d.ts +0 -446
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/discount-mint/structs.js +0 -844
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.d.ts +0 -6
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/index.js +0 -9
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.d.ts +0 -2
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/init.js +0 -69
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.d.ts +0 -94
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/royalty-rule/structs.js +0 -376
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.d.ts +0 -454
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/staking/structs.js +0 -881
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.d.ts +0 -68
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/table-vec/structs.js +0 -274
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.d.ts +0 -1117
- package/dist/src/_dependencies/source/0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196/typus-nft/structs.js +0 -2387
- package/dist/src/_framework/init-loader.d.ts +0 -2
- package/dist/src/_framework/loader.d.ts +0 -17
- package/dist/src/_framework/loader.js +0 -108
- package/dist/src/_framework/reified.d.ts +0 -108
- package/dist/src/_framework/reified.js +0 -237
- package/dist/src/_framework/util.d.ts +0 -35
- package/dist/src/_framework/util.js +0 -396
- package/dist/src/_framework/vector.d.ts +0 -35
- package/dist/src/_framework/vector.js +0 -112
- package/dist/src/pyth.js +0 -1
- package/dist/src/typus_perp/admin/functions.d.ts +0 -59
- package/dist/src/typus_perp/admin/functions.js +0 -122
- package/dist/src/typus_perp/admin/structs.d.ts +0 -529
- package/dist/src/typus_perp/admin/structs.js +0 -1065
- package/dist/src/typus_perp/competition/functions.d.ts +0 -24
- package/dist/src/typus_perp/competition/functions.js +0 -38
- package/dist/src/typus_perp/competition/structs.d.ts +0 -92
- package/dist/src/typus_perp/competition/structs.js +0 -288
- package/dist/src/typus_perp/error/functions.d.ts +0 -73
- package/dist/src/typus_perp/error/functions.js +0 -363
- package/dist/src/typus_perp/escrow/functions.d.ts +0 -17
- package/dist/src/typus_perp/escrow/functions.js +0 -36
- package/dist/src/typus_perp/escrow/structs.d.ts +0 -172
- package/dist/src/typus_perp/escrow/structs.js +0 -324
- package/dist/src/typus_perp/index.d.ts +0 -1
- package/dist/src/typus_perp/index.js +0 -7
- package/dist/src/typus_perp/init.d.ts +0 -2
- package/dist/src/typus_perp/init.js +0 -118
- package/dist/src/typus_perp/lending/functions.d.ts +0 -15
- package/dist/src/typus_perp/lending/functions.js +0 -22
- package/dist/src/typus_perp/lp-pool/functions.d.ts +0 -460
- package/dist/src/typus_perp/lp-pool/functions.js +0 -732
- package/dist/src/typus_perp/lp-pool/structs.d.ts +0 -4268
- package/dist/src/typus_perp/lp-pool/structs.js +0 -6789
- package/dist/src/typus_perp/math/functions.d.ts +0 -29
- package/dist/src/typus_perp/math/functions.js +0 -61
- package/dist/src/typus_perp/position/functions.d.ts +0 -379
- package/dist/src/typus_perp/position/functions.js +0 -713
- package/dist/src/typus_perp/position/structs.d.ts +0 -1064
- package/dist/src/typus_perp/position/structs.js +0 -1450
- package/dist/src/typus_perp/symbol/functions.d.ts +0 -9
- package/dist/src/typus_perp/symbol/functions.js +0 -24
- package/dist/src/typus_perp/symbol/structs.d.ts +0 -81
- package/dist/src/typus_perp/symbol/structs.js +0 -235
- package/dist/src/typus_perp/tlp/functions.d.ts +0 -19
- package/dist/src/typus_perp/tlp/functions.js +0 -40
- package/dist/src/typus_perp/tlp/structs.d.ts +0 -97
- package/dist/src/typus_perp/tlp/structs.js +0 -365
- package/dist/src/typus_perp/token-interface/functions.d.ts +0 -11
- package/dist/src/typus_perp/token-interface/functions.js +0 -22
- package/dist/src/typus_perp/trading/functions.d.ts +0 -812
- package/dist/src/typus_perp/trading/functions.js +0 -1218
- package/dist/src/typus_perp/trading/structs.d.ts +0 -3613
- package/dist/src/typus_perp/trading/structs.js +0 -5813
- package/dist/src/typus_perp/treasury-caps/functions.d.ts +0 -9
- package/dist/src/typus_perp/treasury-caps/functions.js +0 -36
- package/dist/src/typus_perp/treasury-caps/structs.d.ts +0 -55
- package/dist/src/typus_perp/treasury-caps/structs.js +0 -223
- package/dist/src/typus_perp/user-account/functions.d.ts +0 -36
- package/dist/src/typus_perp/user-account/functions.js +0 -70
- package/dist/src/typus_perp/user-account/structs.d.ts +0 -168
- package/dist/src/typus_perp/user-account/structs.js +0 -448
- package/dist/src/typus_stake_pool/admin/functions.d.ts +0 -49
- package/dist/src/typus_stake_pool/admin/functions.js +0 -105
- package/dist/src/typus_stake_pool/admin/structs.d.ts +0 -413
- package/dist/src/typus_stake_pool/admin/structs.js +0 -789
- package/dist/src/typus_stake_pool/index.d.ts +0 -1
- package/dist/src/typus_stake_pool/index.js +0 -7
- package/dist/src/typus_stake_pool/init.d.ts +0 -2
- package/dist/src/typus_stake_pool/init.js +0 -69
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +0 -229
- package/dist/src/typus_stake_pool/stake-pool/functions.js +0 -380
- package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +0 -2477
- package/dist/src/typus_stake_pool/stake-pool/structs.js +0 -4653
- /package/dist/src/{pyth.d.ts → grpc/ledgerService.d.ts} +0 -0
package/dist/src/user/tlp.js
CHANGED
|
@@ -1,67 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __values = (this && this.__values) || function(o) {
|
|
55
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
56
|
-
if (m) return m.call(o);
|
|
57
|
-
if (o && typeof o.length === "number") return {
|
|
58
|
-
next: function () {
|
|
59
|
-
if (o && i >= o.length) o = void 0;
|
|
60
|
-
return { value: o && o[i++], done: !o };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
|
-
};
|
|
65
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
3
|
exports.snapshot = snapshot;
|
|
67
4
|
exports.mintStakeLp = mintStakeLp;
|
|
@@ -72,422 +9,333 @@ exports.redeemTlp = redeemTlp;
|
|
|
72
9
|
exports.claim = claim;
|
|
73
10
|
exports.swap = swap;
|
|
74
11
|
exports.harvestStakeReward = harvestStakeReward;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
});
|
|
12
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
13
|
+
const utils_2 = require("@typus/typus-sdk/dist/src/utils");
|
|
14
|
+
const constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
15
|
+
const __1 = require("..");
|
|
16
|
+
const stake_pool_1 = require("../../src/generated/typus_stake_pool/stake_pool");
|
|
17
|
+
const lp_pool_1 = require("../../src/generated/typus_perp/lp_pool");
|
|
18
|
+
async function snapshot(client, tx, input) {
|
|
19
|
+
tx.add((0, stake_pool_1.snapshot)({
|
|
20
|
+
arguments: {
|
|
21
|
+
version: __1.STAKE_POOL_VERSION,
|
|
22
|
+
registry: __1.STAKE_POOL,
|
|
23
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
24
|
+
UserShareId: BigInt(input.userShareId),
|
|
25
|
+
typusEcosystemVersion: client.config.version.typus,
|
|
26
|
+
typusUserRegistry: client.config.registry.typus.user,
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
return tx;
|
|
95
30
|
}
|
|
96
|
-
function mintStakeLp(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
148
|
-
index: BigInt(0),
|
|
149
|
-
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
150
|
-
coin: coin,
|
|
151
|
-
clock: constants_1.CLOCK,
|
|
152
|
-
});
|
|
153
|
-
if (input.stake) {
|
|
154
|
-
(0, functions_2.stake)(tx, __1.TLP_TOKEN, {
|
|
155
|
-
version: __1.STAKE_POOL_VERSION,
|
|
156
|
-
registry: __1.STAKE_POOL,
|
|
157
|
-
index: BigInt(0),
|
|
158
|
-
lpToken: lpCoin,
|
|
159
|
-
clock: constants_1.CLOCK,
|
|
160
|
-
isAutoCompound: input.isAutoCompound ? BigInt(1) : null,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
tx.transferObjects([lpCoin], input.user);
|
|
165
|
-
}
|
|
166
|
-
return [2 /*return*/, tx];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function stakeLp(config, tx, input) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var coin, destination;
|
|
174
|
-
var _a;
|
|
175
|
-
return __generator(this, function (_b) {
|
|
176
|
-
destination = input.lpCoins.pop();
|
|
177
|
-
if (input.lpCoins.length > 0) {
|
|
178
|
-
tx.mergeCoins(destination, input.lpCoins);
|
|
179
|
-
}
|
|
180
|
-
_a = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _a[0];
|
|
181
|
-
// console.log(iToken);
|
|
182
|
-
if (input.userShareId) {
|
|
183
|
-
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
184
|
-
}
|
|
185
|
-
(0, functions_2.stake)(tx, __1.TLP_TOKEN, {
|
|
31
|
+
async function mintStakeLp(client, tx, input) {
|
|
32
|
+
// update pyth oracle
|
|
33
|
+
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
34
|
+
// console.log("tokens", tokens);
|
|
35
|
+
let cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
36
|
+
let coin;
|
|
37
|
+
let suiCoin;
|
|
38
|
+
if (input.cTOKEN == "SUI" && client.config.sponsored) {
|
|
39
|
+
// split together
|
|
40
|
+
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
|
|
41
|
+
}
|
|
42
|
+
else if (client.config.sponsored) {
|
|
43
|
+
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
44
|
+
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
48
|
+
// no suiCoin
|
|
49
|
+
}
|
|
50
|
+
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
51
|
+
for (let token of tokens) {
|
|
52
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
53
|
+
tx.add((0, lp_pool_1.updateLiquidityValue)({
|
|
54
|
+
arguments: {
|
|
55
|
+
version: __1.PERP_VERSION,
|
|
56
|
+
registry: __1.LP_POOL,
|
|
57
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
58
|
+
oracle: constants_1.oracle[__1.NETWORK][token],
|
|
59
|
+
},
|
|
60
|
+
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
// console.log(iToken);
|
|
64
|
+
if (input.userShareId) {
|
|
65
|
+
harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
66
|
+
}
|
|
67
|
+
let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
|
|
68
|
+
let lpCoin = tx.add((0, lp_pool_1.mintLp)({
|
|
69
|
+
arguments: {
|
|
70
|
+
version: __1.PERP_VERSION,
|
|
71
|
+
registry: __1.LP_POOL,
|
|
72
|
+
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
73
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
74
|
+
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
75
|
+
coin,
|
|
76
|
+
},
|
|
77
|
+
typeArguments: [cToken, lpToken],
|
|
78
|
+
}));
|
|
79
|
+
if (input.stake) {
|
|
80
|
+
tx.add((0, stake_pool_1.stake)({
|
|
81
|
+
arguments: {
|
|
186
82
|
version: __1.STAKE_POOL_VERSION,
|
|
187
83
|
registry: __1.STAKE_POOL,
|
|
188
|
-
index: BigInt(0),
|
|
189
|
-
lpToken:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
84
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
85
|
+
lpToken: lpCoin,
|
|
86
|
+
UserShareId: null,
|
|
87
|
+
},
|
|
88
|
+
typeArguments: [lpToken],
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
tx.transferObjects([lpCoin], input.user);
|
|
93
|
+
}
|
|
94
|
+
return tx;
|
|
196
95
|
}
|
|
197
|
-
function
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
220
|
-
});
|
|
96
|
+
async function stakeLp(client, tx, input) {
|
|
97
|
+
var lpCoin;
|
|
98
|
+
let destination = input.lpCoins.pop();
|
|
99
|
+
if (input.lpCoins.length > 0) {
|
|
100
|
+
tx.mergeCoins(destination, input.lpCoins);
|
|
101
|
+
}
|
|
102
|
+
[lpCoin] = tx.splitCoins(destination, [input.amount]);
|
|
103
|
+
// console.log(iToken);
|
|
104
|
+
if (input.userShareId) {
|
|
105
|
+
harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
106
|
+
}
|
|
107
|
+
tx.add((0, stake_pool_1.stake)({
|
|
108
|
+
arguments: {
|
|
109
|
+
version: __1.STAKE_POOL_VERSION,
|
|
110
|
+
registry: __1.STAKE_POOL,
|
|
111
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
112
|
+
lpToken: lpCoin,
|
|
113
|
+
UserShareId: null,
|
|
114
|
+
},
|
|
115
|
+
typeArguments: [(0, utils_1.normalizeStructTag)(input.stakePool.pool_info.stake_token.name)],
|
|
116
|
+
}));
|
|
117
|
+
return tx;
|
|
221
118
|
}
|
|
222
|
-
function
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
250
|
-
finally {
|
|
251
|
-
try {
|
|
252
|
-
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
253
|
-
}
|
|
254
|
-
finally { if (e_2) throw e_2.error; }
|
|
255
|
-
}
|
|
256
|
-
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
257
|
-
(0, functions_2.unsubscribe)(tx, __1.TLP_TOKEN, {
|
|
258
|
-
version: __1.STAKE_POOL_VERSION,
|
|
259
|
-
registry: __1.STAKE_POOL,
|
|
260
|
-
index: BigInt(0),
|
|
261
|
-
userShareId: BigInt(input.userShareId),
|
|
262
|
-
clock: constants_1.CLOCK,
|
|
263
|
-
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
264
|
-
});
|
|
265
|
-
lpCoin = (0, functions_2.unstake)(tx, __1.TLP_TOKEN, {
|
|
266
|
-
version: __1.STAKE_POOL_VERSION,
|
|
267
|
-
registry: __1.STAKE_POOL,
|
|
268
|
-
index: BigInt(0),
|
|
269
|
-
userShareId: BigInt(input.userShareId),
|
|
270
|
-
clock: constants_1.CLOCK,
|
|
271
|
-
});
|
|
272
|
-
balance = tx.moveCall({
|
|
273
|
-
target: "0x2::coin::into_balance",
|
|
274
|
-
typeArguments: [__1.TLP_TOKEN],
|
|
275
|
-
arguments: [lpCoin],
|
|
276
|
-
});
|
|
277
|
-
(0, functions_1.redeem)(tx, __1.TLP_TOKEN, {
|
|
278
|
-
version: __1.PERP_VERSION,
|
|
279
|
-
registry: __1.LP_POOL,
|
|
280
|
-
index: BigInt(0),
|
|
281
|
-
clock: constants_1.CLOCK,
|
|
282
|
-
balance: balance,
|
|
283
|
-
});
|
|
284
|
-
return [2 /*return*/, tx];
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
});
|
|
119
|
+
async function unstake(client, tx, input) {
|
|
120
|
+
harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
121
|
+
let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
|
|
122
|
+
tx.add((0, stake_pool_1.unsubscribe)({
|
|
123
|
+
arguments: {
|
|
124
|
+
version: __1.STAKE_POOL_VERSION,
|
|
125
|
+
registry: __1.STAKE_POOL,
|
|
126
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
127
|
+
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
128
|
+
UserShareId: BigInt(input.userShareId),
|
|
129
|
+
},
|
|
130
|
+
typeArguments: [lpToken],
|
|
131
|
+
}));
|
|
132
|
+
let lpCoin = tx.add((0, stake_pool_1.unstake)({
|
|
133
|
+
arguments: {
|
|
134
|
+
version: __1.STAKE_POOL_VERSION,
|
|
135
|
+
registry: __1.STAKE_POOL,
|
|
136
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
137
|
+
UserShareId: BigInt(input.userShareId),
|
|
138
|
+
},
|
|
139
|
+
typeArguments: [lpToken],
|
|
140
|
+
}));
|
|
141
|
+
tx.transferObjects([lpCoin], input.user);
|
|
142
|
+
return tx;
|
|
288
143
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
burnCoin = tx.splitCoins(lpCoin, [input.share]);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
burnCoin = lpCoin;
|
|
333
|
-
}
|
|
334
|
-
balance = tx.moveCall({
|
|
335
|
-
target: "0x2::coin::into_balance",
|
|
336
|
-
typeArguments: [__1.TLP_TOKEN],
|
|
337
|
-
arguments: [burnCoin],
|
|
338
|
-
});
|
|
339
|
-
(0, functions_1.redeem)(tx, __1.TLP_TOKEN, {
|
|
340
|
-
version: __1.PERP_VERSION,
|
|
341
|
-
registry: __1.LP_POOL,
|
|
342
|
-
index: BigInt(0),
|
|
343
|
-
clock: constants_1.CLOCK,
|
|
344
|
-
balance: balance,
|
|
345
|
-
});
|
|
346
|
-
return [2 /*return*/, tx];
|
|
347
|
-
}
|
|
348
|
-
});
|
|
144
|
+
async function unstakeRedeem(client, tx, input) {
|
|
145
|
+
// update pyth oracle
|
|
146
|
+
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
147
|
+
let suiCoin;
|
|
148
|
+
if (client.config.sponsored) {
|
|
149
|
+
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
150
|
+
}
|
|
151
|
+
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
152
|
+
for (let token of tokens) {
|
|
153
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
154
|
+
(0, lp_pool_1.updateLiquidityValue)({
|
|
155
|
+
arguments: { version: __1.PERP_VERSION, registry: __1.LP_POOL, index: BigInt(input.perpIndex ?? 0), oracle: constants_1.oracle[__1.NETWORK][token] },
|
|
156
|
+
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
157
|
+
})(tx);
|
|
158
|
+
}
|
|
159
|
+
harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
160
|
+
let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
|
|
161
|
+
tx.add((0, stake_pool_1.unsubscribe)({
|
|
162
|
+
arguments: {
|
|
163
|
+
version: __1.STAKE_POOL_VERSION,
|
|
164
|
+
registry: __1.STAKE_POOL,
|
|
165
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
166
|
+
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
167
|
+
UserShareId: BigInt(input.userShareId),
|
|
168
|
+
},
|
|
169
|
+
typeArguments: [lpToken],
|
|
170
|
+
}));
|
|
171
|
+
let lpCoin = tx.add((0, stake_pool_1.unstake)({
|
|
172
|
+
arguments: {
|
|
173
|
+
version: __1.STAKE_POOL_VERSION,
|
|
174
|
+
registry: __1.STAKE_POOL,
|
|
175
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
176
|
+
UserShareId: BigInt(input.userShareId),
|
|
177
|
+
},
|
|
178
|
+
typeArguments: [lpToken],
|
|
179
|
+
}));
|
|
180
|
+
let balance = tx.moveCall({
|
|
181
|
+
target: `0x2::coin::into_balance`,
|
|
182
|
+
typeArguments: [input.lpPool.lp_token_type.name],
|
|
183
|
+
arguments: [lpCoin],
|
|
349
184
|
});
|
|
185
|
+
tx.add((0, lp_pool_1.redeem)({
|
|
186
|
+
arguments: {
|
|
187
|
+
version: __1.PERP_VERSION,
|
|
188
|
+
registry: __1.LP_POOL,
|
|
189
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
190
|
+
balance,
|
|
191
|
+
},
|
|
192
|
+
typeArguments: [input.lpPool.lp_token_type.name],
|
|
193
|
+
}));
|
|
194
|
+
return tx;
|
|
350
195
|
}
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
registry: __1.LP_POOL,
|
|
389
|
-
index: BigInt(0),
|
|
390
|
-
clock: constants_1.CLOCK,
|
|
391
|
-
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
392
|
-
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
393
|
-
});
|
|
394
|
-
tx.transferObjects([token], input.user);
|
|
395
|
-
return [2 /*return*/, tx];
|
|
396
|
-
}
|
|
397
|
-
});
|
|
196
|
+
async function redeemTlp(client, tx, input) {
|
|
197
|
+
// update pyth oracle
|
|
198
|
+
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
199
|
+
let suiCoin;
|
|
200
|
+
if (client.config.sponsored) {
|
|
201
|
+
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
202
|
+
}
|
|
203
|
+
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
204
|
+
for (let token of tokens) {
|
|
205
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
206
|
+
tx.add((0, lp_pool_1.updateLiquidityValue)({
|
|
207
|
+
arguments: {
|
|
208
|
+
version: __1.PERP_VERSION,
|
|
209
|
+
registry: __1.LP_POOL,
|
|
210
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
211
|
+
oracle: constants_1.oracle[__1.NETWORK][token],
|
|
212
|
+
},
|
|
213
|
+
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
let destination = input.lpCoins.pop();
|
|
217
|
+
if (input.lpCoins.length > 0) {
|
|
218
|
+
tx.mergeCoins(destination, input.lpCoins);
|
|
219
|
+
}
|
|
220
|
+
let lpCoin = tx.object(destination);
|
|
221
|
+
let burnCoin;
|
|
222
|
+
if (input.share) {
|
|
223
|
+
burnCoin = tx.splitCoins(lpCoin, [input.share]);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
burnCoin = lpCoin;
|
|
227
|
+
}
|
|
228
|
+
let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
|
|
229
|
+
let balance = tx.moveCall({
|
|
230
|
+
target: `0x2::coin::into_balance`,
|
|
231
|
+
typeArguments: [lpToken],
|
|
232
|
+
arguments: [burnCoin],
|
|
398
233
|
});
|
|
234
|
+
tx.add((0, lp_pool_1.redeem)({
|
|
235
|
+
arguments: {
|
|
236
|
+
version: __1.PERP_VERSION,
|
|
237
|
+
registry: __1.LP_POOL,
|
|
238
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
239
|
+
balance,
|
|
240
|
+
},
|
|
241
|
+
typeArguments: [lpToken],
|
|
242
|
+
}));
|
|
243
|
+
return tx;
|
|
399
244
|
}
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
registry: __1.LP_POOL,
|
|
429
|
-
clock: constants_1.CLOCK,
|
|
430
|
-
index: BigInt(0),
|
|
431
|
-
oracleFromToken: constants_1.oracle[__1.NETWORK][input.FROM_TOKEN],
|
|
432
|
-
oracleToToken: constants_1.oracle[__1.NETWORK][input.TO_TOKEN],
|
|
433
|
-
fromCoin: coin,
|
|
434
|
-
minToAmount: BigInt(0),
|
|
435
|
-
});
|
|
436
|
-
tx.transferObjects([token], input.user);
|
|
437
|
-
return [2 /*return*/, tx];
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
});
|
|
245
|
+
async function claim(client, tx, input) {
|
|
246
|
+
// update pyth oracle
|
|
247
|
+
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
248
|
+
let suiCoin;
|
|
249
|
+
if (client.config.sponsored) {
|
|
250
|
+
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
251
|
+
}
|
|
252
|
+
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
253
|
+
for (let token of tokens) {
|
|
254
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
255
|
+
(0, lp_pool_1.updateLiquidityValue)({
|
|
256
|
+
arguments: { version: __1.PERP_VERSION, registry: __1.LP_POOL, index: BigInt(input.perpIndex ?? 0), oracle: constants_1.oracle[__1.NETWORK][token] },
|
|
257
|
+
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
258
|
+
})(tx);
|
|
259
|
+
}
|
|
260
|
+
let cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
261
|
+
let token = (0, lp_pool_1.claim)({
|
|
262
|
+
arguments: {
|
|
263
|
+
version: __1.PERP_VERSION,
|
|
264
|
+
registry: __1.LP_POOL,
|
|
265
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
266
|
+
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
267
|
+
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
268
|
+
},
|
|
269
|
+
typeArguments: [(0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name), cToken],
|
|
270
|
+
})(tx);
|
|
271
|
+
tx.transferObjects([token], input.user);
|
|
272
|
+
return tx;
|
|
441
273
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
274
|
+
async function swap(client, tx, input) {
|
|
275
|
+
let fromToken = constants_1.tokenType[__1.NETWORK][input.FROM_TOKEN];
|
|
276
|
+
let toToken = constants_1.tokenType[__1.NETWORK][input.TO_TOKEN];
|
|
277
|
+
let coin;
|
|
278
|
+
let suiCoin;
|
|
279
|
+
if (input.FROM_TOKEN == "SUI" && client.config.sponsored) {
|
|
280
|
+
// split together
|
|
281
|
+
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, "2"], client.config.sponsored);
|
|
282
|
+
}
|
|
283
|
+
else if (client.config.sponsored) {
|
|
284
|
+
coin = (0, utils_2.splitCoin)(tx, fromToken, input.coins, input.amount, client.config.sponsored);
|
|
285
|
+
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, "2", client.config.sponsored);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
coin = (0, utils_2.splitCoin)(tx, fromToken, input.coins, input.amount, client.config.sponsored);
|
|
289
|
+
// no suiCoin
|
|
290
|
+
}
|
|
291
|
+
await (0, utils_2.updatePyth)(client.pythClient, tx, [input.FROM_TOKEN, input.TO_TOKEN], suiCoin);
|
|
292
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, input.FROM_TOKEN);
|
|
293
|
+
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, input.TO_TOKEN);
|
|
294
|
+
let token = (0, lp_pool_1.swap)({
|
|
295
|
+
arguments: {
|
|
296
|
+
version: __1.PERP_VERSION,
|
|
297
|
+
registry: __1.LP_POOL,
|
|
298
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
299
|
+
oracleFromToken: constants_1.oracle[__1.NETWORK][input.FROM_TOKEN],
|
|
300
|
+
oracleToToken: constants_1.oracle[__1.NETWORK][input.TO_TOKEN],
|
|
301
|
+
fromCoin: coin,
|
|
302
|
+
minToAmount: BigInt(0),
|
|
303
|
+
},
|
|
304
|
+
typeArguments: [fromToken, toToken],
|
|
305
|
+
})(tx);
|
|
306
|
+
tx.transferObjects([token], input.user);
|
|
307
|
+
return tx;
|
|
308
|
+
}
|
|
309
|
+
async function harvestStakeReward(client, tx, input) {
|
|
310
|
+
let iTokens = input.stakePool.incentives.map((i) => i.token_type.name);
|
|
311
|
+
snapshot(client, tx, { userShareId: input.userShareId });
|
|
312
|
+
for (let iToken of iTokens) {
|
|
313
|
+
// console.log(iToken);
|
|
314
|
+
let iCoin = tx.add((0, stake_pool_1.harvestPerUserShare)({
|
|
315
|
+
arguments: {
|
|
449
316
|
version: __1.STAKE_POOL_VERSION,
|
|
450
317
|
registry: __1.STAKE_POOL,
|
|
451
|
-
index: BigInt(0),
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
clock: constants_1.CLOCK,
|
|
475
|
-
isAutoCompound: null,
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
tx.transferObjects([iCoin], input.user);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
484
|
-
finally {
|
|
485
|
-
try {
|
|
486
|
-
if (iTokens_1_1 && !iTokens_1_1.done && (_a = iTokens_1.return)) _a.call(iTokens_1);
|
|
487
|
-
}
|
|
488
|
-
finally { if (e_5) throw e_5.error; }
|
|
489
|
-
}
|
|
490
|
-
return [2 /*return*/, tx];
|
|
491
|
-
});
|
|
492
|
-
});
|
|
318
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
319
|
+
UserShareId: BigInt(input.userShareId),
|
|
320
|
+
},
|
|
321
|
+
typeArguments: [iToken],
|
|
322
|
+
}));
|
|
323
|
+
if (iToken.endsWith("TLP")) {
|
|
324
|
+
// stake
|
|
325
|
+
tx.add((0, stake_pool_1.stake)({
|
|
326
|
+
arguments: {
|
|
327
|
+
version: __1.STAKE_POOL_VERSION,
|
|
328
|
+
registry: __1.STAKE_POOL,
|
|
329
|
+
index: BigInt(input.perpIndex ?? 0),
|
|
330
|
+
lpToken: iCoin,
|
|
331
|
+
UserShareId: BigInt(input.userShareId),
|
|
332
|
+
},
|
|
333
|
+
typeArguments: [(0, utils_1.normalizeStructTag)(input.stakePool.pool_info.stake_token.name)],
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
tx.transferObjects([iCoin], input.user);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return tx;
|
|
493
341
|
}
|