@wireio/stake 0.6.0 → 0.7.1
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/lib/stake.browser.js +196 -224
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +37 -36
- package/lib/stake.js +199 -227
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +196 -224
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
- package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +33 -2
- package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/BAR.sol/BAR.json +2 -18
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +26 -42
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +2 -31
- package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/OutpostErrors.sol/OutpostErrors.json +2 -18
- package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/Pool.sol/Pool.json +2 -18
- package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json +2 -18
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +1 -1
- package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +2 -18
- package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.dbg.json +1 -1
- package/src/assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json +2 -2
- package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.dbg.json +1 -1
- package/src/assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json +2 -2
- package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.dbg.json +1 -1
- package/src/assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json +2 -2
- package/src/networks/ethereum/contract.ts +24 -57
- package/src/networks/ethereum/ethereum.ts +12 -3
- package/src/networks/solana/solana.ts +160 -87
- package/src/staker.ts +1 -0
- package/src/types.ts +12 -11
|
@@ -442,8 +442,8 @@
|
|
|
442
442
|
"type": "function"
|
|
443
443
|
}
|
|
444
444
|
],
|
|
445
|
-
"bytecode": "0x60806040523480156200001157600080fd5b50604051806040016040528060098152602001682a32b9ba2a37b5b2b760b91b8152506040518060400160405280600381526020016205343560ec1b815250816000908162000061919062000504565b50600162000070828262000504565b505050620000863360006200008c60201b60201c565b620005d0565b6001600160a01b038216620000bc57604051633250574960e11b8152600060048201526024015b60405180910390fd5b6000620000cb838383620000ff565b90506001600160a01b03811615620000fa576040516339e3563760e11b815260006004820152602401620000b3565b505050565b6000828152600260205260408120546001600160a01b03908116908316156200012f576200012f818486620001fe565b6001600160a01b038116156200016f576200014e600085818062000268565b6001600160a01b038116600090815260036020526040902080546000190190555b6001600160a01b038516156200019f576001600160a01b0385166000908152600360205260409020805460010190555b60008481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6200020b83838362000396565b620000fa576001600160a01b0383166200023c57604051637e27328960e01b815260048101829052602401620000b3565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401620000b3565b80806200027d57506001600160a01b03821615155b156200036657600062000290846200041f565b90506001600160a01b03831615801590620002bd5750826001600160a01b0316816001600160a01b031614155b8015620002f057506001600160a01b0380821660009081526005602090815260408083209387168352929052205460ff16155b156200031b5760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401620000b3565b8115620003645783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03831615801590620004175750826001600160a01b0316846001600160a01b03161480620003f257506001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b806200041757506000828152600460205260409020546001600160a01b038481169116145b949350505050565b6000818152600260205260408120546001600160a01b0316806200045a57604051637e27328960e01b815260048101849052602401620000b3565b92915050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200048b57607f821691505b602082108103620004ac57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620000fa57600081815260208120601f850160051c81016020861015620004db5750805b601f850160051c820191505b81811015620004fc57828155600101620004e7565b505050505050565b81516001600160401b0381111562000520576200052062000460565b620005388162000531845462000476565b84620004b2565b602080601f831160018114620005705760008415620005575750858301515b600019600386901b1c1916600185901b178555620004fc565b600085815260208120601f198616915b82811015620005a15788860151825594840194600190910190840162000580565b5085821015620005c05787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61124280620005e06000396000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c80636352211e1161008c578063a22cb46511610066578063a22cb465146101c3578063b88d4fde146101d6578063c87b56dd146101e9578063e985e9c5146101fc57600080fd5b80636352211e1461018757806370a082311461019a57806395d89b41146101bb57600080fd5b8063095ea7b3116100bd578063095ea7b31461014c57806323b872dd1461016157806342842e0e1461017457600080fd5b806301ffc9a7146100e457806306fdde031461010c578063081812fc14610121575b600080fd5b6100f76100f2366004610e45565b610238565b60405190151581526020015b60405180910390f35b61011461031d565b6040516101039190610ed0565b61013461012f366004610ee3565b6103af565b6040516001600160a01b039091168152602001610103565b61015f61015a366004610f18565b6103d8565b005b61015f61016f366004610f42565b6103e7565b61015f610182366004610f42565b6104a9565b610134610195366004610ee3565b6104c9565b6101ad6101a8366004610f7e565b6104d4565b604051908152602001610103565b610114610535565b61015f6101d1366004610f99565b610544565b61015f6101e4366004611004565b61054f565b6101146101f7366004610ee3565b610566565b6100f761020a3660046110fe565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806102cb57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061031757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60606000805461032c90611131565b80601f016020809104026020016040519081016040528092919081815260200182805461035890611131565b80156103a55780601f1061037a576101008083540402835291602001916103a5565b820191906000526020600020905b81548152906001019060200180831161038857829003601f168201915b5050505050905090565b60006103ba826105db565b506000828152600460205260409020546001600160a01b0316610317565b6103e382823361062d565b5050565b6001600160a01b03821661042f576040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b600061043c83833361063a565b9050836001600160a01b0316816001600160a01b0316146104a3576040517f64283d7b0000000000000000000000000000000000000000000000000000000081526001600160a01b0380861660048301526024820184905282166044820152606401610426565b50505050565b6104c48383836040518060200160405280600081525061054f565b505050565b6000610317826105db565b60006001600160a01b038216610519576040517f89c62b6400000000000000000000000000000000000000000000000000000000815260006004820152602401610426565b506001600160a01b031660009081526003602052604090205490565b60606001805461032c90611131565b6103e3338383610769565b61055a8484846103e7565b6104a38484848461083f565b6060610571826105db565b50600061058960408051602081019091526000815290565b905060008151116105a957604051806020016040528060008152506105d4565b806105b384610a02565b6040516020016105c4929190611184565b6040516020818303038152906040525b9392505050565b6000818152600260205260408120546001600160a01b031680610317576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101849052602401610426565b6104c48383836001610ac0565b6000828152600260205260408120546001600160a01b039081169083161561066757610667818486610c16565b6001600160a01b038116156106c357610684600085600080610ac0565b6001600160a01b038116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190555b6001600160a01b038516156106f2576001600160a01b0385166000908152600360205260409020805460010190555b60008481526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6001600160a01b0382166107b4576040517f5b08ba180000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610426565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b156104a3576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063150b7a029061089a9033908890879087906004016111b3565b6020604051808303816000875af19250505080156108f3575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526108f0918101906111ef565b60015b610975573d808015610921576040519150601f19603f3d011682016040523d82523d6000602084013e610926565b606091505b50805160000361096d576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610426565b805181602001fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081167f150b7a0200000000000000000000000000000000000000000000000000000000146109fb576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610426565b5050505050565b60606000610a0f83610cac565b600101905060008167ffffffffffffffff811115610a2f57610a2f610fd5565b6040519080825280601f01601f191660200182016040528015610a59576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084610a6357509392505050565b8080610ad457506001600160a01b03821615155b15610bce576000610ae4846105db565b90506001600160a01b03831615801590610b105750826001600160a01b0316816001600160a01b031614155b8015610b4257506001600160a01b0380821660009081526005602090815260408083209387168352929052205460ff16155b15610b84576040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610426565b8115610bcc5783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b610c21838383610d8e565b6104c4576001600160a01b038316610c68576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101829052602401610426565b6040517f177e802f0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260248101829052604401610426565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610cf5577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310610d21576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610d3f57662386f26fc10000830492506010015b6305f5e1008310610d57576305f5e100830492506008015b6127108310610d6b57612710830492506004015b60648310610d7d576064830492506002015b600a83106103175760010192915050565b60006001600160a01b03831615801590610e0c5750826001600160a01b0316846001600160a01b03161480610de857506001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b80610e0c57506000828152600460205260409020546001600160a01b038481169116145b949350505050565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610e4257600080fd5b50565b600060208284031215610e5757600080fd5b81356105d481610e14565b60005b83811015610e7d578181015183820152602001610e65565b50506000910152565b60008151808452610e9e816020860160208601610e62565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006105d46020830184610e86565b600060208284031215610ef557600080fd5b5035919050565b80356001600160a01b0381168114610f1357600080fd5b919050565b60008060408385031215610f2b57600080fd5b610f3483610efc565b946020939093013593505050565b600080600060608486031215610f5757600080fd5b610f6084610efc565b9250610f6e60208501610efc565b9150604084013590509250925092565b600060208284031215610f9057600080fd5b6105d482610efc565b60008060408385031215610fac57600080fd5b610fb583610efc565b915060208301358015158114610fca57600080fd5b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561101a57600080fd5b61102385610efc565b935061103160208601610efc565b925060408501359150606085013567ffffffffffffffff8082111561105557600080fd5b818701915087601f83011261106957600080fd5b81358181111561107b5761107b610fd5565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156110c1576110c1610fd5565b816040528281528a60208487010111156110da57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561111157600080fd5b61111a83610efc565b915061112860208401610efc565b90509250929050565b600181811c9082168061114557607f821691505b60208210810361117e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008351611196818460208801610e62565b8351908301906111aa818360208801610e62565b01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526111e56080830184610e86565b9695505050505050565b60006020828403121561120157600080fd5b81516105d481610e1456fea2646970667358221220f01353e907bf32e618b272b375495d5c57e47c264dd1ba09828ba6800e20cae964736f6c63430008140033",
|
|
446
|
-
"deployedBytecode": "
|
|
445
|
+
"bytecode": "0x6080346103bf576040906001600160401b03818301818111838210176103a957835260098252602090682a32b9ba2a37b5b2b760b91b82840152835191848301838110838211176103a95785526003918284526205343560ec1b8285015284518181116103a9576000948554916001978884811c9416801561039f575b8685101461038b578190601f9485811161033d575b5086908583116001146102df5789926102d4575b505060001982881b1c191690881b1786555b80519283116102c05786548781811c911680156102b6575b858210146102a25790818385949311610252575b50849183116001146101f45786926101e9575b505060001982851b1c191690851b1784555b33156101d1578280526002808252858420546001600160a01b03169485151593919291846101a6575b3386528252868520908154019055838052528382203360018060a01b03198254161790558184519333907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8380a4610191578251610b3090816103c58239f35b6339e3563760e11b8252600482015260249150fd5b6004835287862080546001600160a01b03191690558686528083528786208054600019019055610131565b8451633250574960e11b815260048101849052602490fd5b0151905038806100f6565b8787528487208894509190601f198416885b8782821061023c5750508411610224575b505050811b018455610108565b015160001983871b60f8161c19169055388080610217565b8385015186558b97909501949384019301610206565b909192508787528487208380860160051c820192878710610299575b9186958b929594930160051c01915b82811061028b5750506100e3565b8981558695508a910161027d565b9250819261026e565b634e487b7160e01b87526022600452602487fd5b90607f16906100cf565b634e487b7160e01b86526041600452602486fd5b0151905038806100a5565b898052878a208b94509190601f1984168b5b8a828210610327575050841161030f575b505050811b0186556100b7565b0151600019838a1b60f8161c19169055388080610302565b8385015186558e979095019493840193016102f1565b9091508880528689208580850160051c820192898610610382575b918c91869594930160051c01915b828110610374575050610091565b8b81558594508c9101610366565b92508192610358565b634e487b7160e01b88526022600452602488fd5b93607f169361007c565b634e487b7160e01b600052604160045260246000fd5b600080fdfe608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a7146106505750816306fdde0314610583578163081812fc14610547578163095ea7b31461046a57816323b872dd1461045257816342842e0e146104295781636352211e146103f857816370a08231146103a357816395d89b4114610286578163a22cb465146101e4578163b88d4fde14610156578163c87b56dd14610104575063e985e9c5146100b457600080fd5b3461010057806003193601126101005760ff816020936100d26106fb565b6100da610716565b6001600160a01b0391821683526005875283832091168252855220549151911615158152f35b5080fd5b838334610100576020366003190112610100576101246101529335610abf565b5081815161013181610761565b5280519161013e83610761565b8252519182916020835260208301906106bb565b0390f35b919050346101e05760803660031901126101e0576101726106fb565b61017a610716565b846064359467ffffffffffffffff8611610100573660238701121561010057850135946101b26101a9876107b5565b95519586610793565b858552366024878301011161010057856101dd9660246020930183880137850101526044359161096a565b80f35b8280fd5b919050346101e057806003193601126101e0576101ff6106fb565b9060243591821515809303610282576001600160a01b031692831561026d5750338452600560205280842083855260205280842060ff1981541660ff8416179055519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b836024925191630b61174360e31b8352820152fd5b8480fd5b8284346103a057806003193601126103a05781519181600192600154938460011c9160018616958615610396575b6020968785108114610383578899509688969785829a52918260001461035c575050600114610300575b50505061015292916102f1910385610793565b519282849384528301906106bb565b9190869350600183527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b82841061034457505050820101816102f16101526102de565b8054848a01860152889550879490930192810161032b565b60ff19168782015293151560051b860190930193508492506102f1915061015290506102de565b634e487b7160e01b835260228a52602483fd5b92607f16926102b4565b80fd5b8284346103a05760203660031901126103a0576001600160a01b036103c66106fb565b169283156103e35750806020938392526003845220549051908152f35b91516322718ad960e21b815291820152602490fd5b8284346103a05760203660031901126103a0575061041860209235610abf565b90516001600160a01b039091168152f35b505034610100576101dd9061043d3661072c565b9192519261044a84610761565b85845261096a565b83346103a0576101dd6104643661072c565b916107d1565b919050346101e057806003193601126101e0576104856106fb565b9160243561049281610abf565b33151580610534575b8061050b575b6104f5576001600160a01b039485169482918691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258880a48452602052822080546001600160a01b031916909117905580f35b835163a9fbf51f60e01b81523381850152602490fd5b506001600160a01b03811686526005602090815284872033885290528386205460ff16156104a1565b506001600160a01b03811633141561049b565b9050346101e05760203660031901126101e05791826020933561056981610abf565b50825283528190205490516001600160a01b039091168152f35b8284346103a057806003193601126103a0578151918182549260018460011c9160018616958615610646575b6020968785108114610383578899509688969785829a52918260001461035c5750506001146105eb5750505061015292916102f1910385610793565b91908693508280527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b82841061062e57505050820101816102f16101526102de565b8054848a018601528895508794909301928101610615565b92607f16926105af565b8491346101e05760203660031901126101e0573563ffffffff60e01b81168091036101e057602092506380ac58cd60e01b81149081156106aa575b8115610699575b5015158152f35b6301ffc9a760e01b14905083610692565b635b5e139f60e01b8114915061068b565b919082519283825260005b8481106106e7575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016106c6565b600435906001600160a01b038216820361071157565b600080fd5b602435906001600160a01b038216820361071157565b6060906003190112610711576001600160a01b0390600435828116810361071157916024359081168103610711579060443590565b6020810190811067ffffffffffffffff82111761077d57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761077d57604052565b67ffffffffffffffff811161077d57601f01601f191660200190565b916001600160a01b03918216918215610951576000938285528260209460028652604095848789205416968791331515806108bb575b509060027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928461088c575b858c5260038152828c2080546001019055868c5252808a2080546001600160a01b03191685179055519880a41680830361086d5750505050565b6364283d7b60e01b845260048401526024830152604482015260649150fd5b868c5260048152828c2080546001600160a01b0319169055848c5260038152828c208054600019019055610833565b91939450915080610910575b156108d757859291879138610807565b5084866108f4576024915190637e27328960e01b82526004820152fd5b604491519063177e802f60e01b82523360048301526024820152fd5b503387148015610935575b806108c75750858852600481523385838a205416146108c7565b5086885260058152818820338952815260ff828920541661091b565b604051633250574960e11b815260006004820152602490fd5b9290926109788385836107d1565b833b610985575b50505050565b604051630a85bd0160e11b8082523360048301526001600160a01b03928316602483015260448201949094526080606482015294931692602092909185906109d19060848301906106bb565b039483816000978189895af1869181610a7b575b50610a46575050503d600014610a3d573d6109ff816107b5565b90610a0d6040519283610793565b81528093823d92013e5b82519283610a3857604051633250574960e11b815260048101849052602490fd5b019050fd5b60609250610a17565b919450915063ffffffff60e01b1603610a6357503880808061097f565b60249060405190633250574960e11b82526004820152fd5b9091508481813d8311610ab8575b610a938183610793565b81010312610ab457516001600160e01b031981168103610ab45790386109e5565b8680fd5b503d610a89565b6000818152600260205260409020546001600160a01b0316908115610ae2575090565b60249060405190637e27328960e01b82526004820152fdfea264697066735822122044235653b73457193b8d7b6102b48056d30e5fbb4bd4af7fe5e9f92b11d1c41c64736f6c63430008190033",
|
|
446
|
+
"deployedBytecode": "0x608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a7146106505750816306fdde0314610583578163081812fc14610547578163095ea7b31461046a57816323b872dd1461045257816342842e0e146104295781636352211e146103f857816370a08231146103a357816395d89b4114610286578163a22cb465146101e4578163b88d4fde14610156578163c87b56dd14610104575063e985e9c5146100b457600080fd5b3461010057806003193601126101005760ff816020936100d26106fb565b6100da610716565b6001600160a01b0391821683526005875283832091168252855220549151911615158152f35b5080fd5b838334610100576020366003190112610100576101246101529335610abf565b5081815161013181610761565b5280519161013e83610761565b8252519182916020835260208301906106bb565b0390f35b919050346101e05760803660031901126101e0576101726106fb565b61017a610716565b846064359467ffffffffffffffff8611610100573660238701121561010057850135946101b26101a9876107b5565b95519586610793565b858552366024878301011161010057856101dd9660246020930183880137850101526044359161096a565b80f35b8280fd5b919050346101e057806003193601126101e0576101ff6106fb565b9060243591821515809303610282576001600160a01b031692831561026d5750338452600560205280842083855260205280842060ff1981541660ff8416179055519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b836024925191630b61174360e31b8352820152fd5b8480fd5b8284346103a057806003193601126103a05781519181600192600154938460011c9160018616958615610396575b6020968785108114610383578899509688969785829a52918260001461035c575050600114610300575b50505061015292916102f1910385610793565b519282849384528301906106bb565b9190869350600183527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b82841061034457505050820101816102f16101526102de565b8054848a01860152889550879490930192810161032b565b60ff19168782015293151560051b860190930193508492506102f1915061015290506102de565b634e487b7160e01b835260228a52602483fd5b92607f16926102b4565b80fd5b8284346103a05760203660031901126103a0576001600160a01b036103c66106fb565b169283156103e35750806020938392526003845220549051908152f35b91516322718ad960e21b815291820152602490fd5b8284346103a05760203660031901126103a0575061041860209235610abf565b90516001600160a01b039091168152f35b505034610100576101dd9061043d3661072c565b9192519261044a84610761565b85845261096a565b83346103a0576101dd6104643661072c565b916107d1565b919050346101e057806003193601126101e0576104856106fb565b9160243561049281610abf565b33151580610534575b8061050b575b6104f5576001600160a01b039485169482918691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258880a48452602052822080546001600160a01b031916909117905580f35b835163a9fbf51f60e01b81523381850152602490fd5b506001600160a01b03811686526005602090815284872033885290528386205460ff16156104a1565b506001600160a01b03811633141561049b565b9050346101e05760203660031901126101e05791826020933561056981610abf565b50825283528190205490516001600160a01b039091168152f35b8284346103a057806003193601126103a0578151918182549260018460011c9160018616958615610646575b6020968785108114610383578899509688969785829a52918260001461035c5750506001146105eb5750505061015292916102f1910385610793565b91908693508280527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b82841061062e57505050820101816102f16101526102de565b8054848a018601528895508794909301928101610615565b92607f16926105af565b8491346101e05760203660031901126101e0573563ffffffff60e01b81168091036101e057602092506380ac58cd60e01b81149081156106aa575b8115610699575b5015158152f35b6301ffc9a760e01b14905083610692565b635b5e139f60e01b8114915061068b565b919082519283825260005b8481106106e7575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016106c6565b600435906001600160a01b038216820361071157565b600080fd5b602435906001600160a01b038216820361071157565b6060906003190112610711576001600160a01b0390600435828116810361071157916024359081168103610711579060443590565b6020810190811067ffffffffffffffff82111761077d57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761077d57604052565b67ffffffffffffffff811161077d57601f01601f191660200190565b916001600160a01b03918216918215610951576000938285528260209460028652604095848789205416968791331515806108bb575b509060027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928461088c575b858c5260038152828c2080546001019055868c5252808a2080546001600160a01b03191685179055519880a41680830361086d5750505050565b6364283d7b60e01b845260048401526024830152604482015260649150fd5b868c5260048152828c2080546001600160a01b0319169055848c5260038152828c208054600019019055610833565b91939450915080610910575b156108d757859291879138610807565b5084866108f4576024915190637e27328960e01b82526004820152fd5b604491519063177e802f60e01b82523360048301526024820152fd5b503387148015610935575b806108c75750858852600481523385838a205416146108c7565b5086885260058152818820338952815260ff828920541661091b565b604051633250574960e11b815260006004820152602490fd5b9290926109788385836107d1565b833b610985575b50505050565b604051630a85bd0160e11b8082523360048301526001600160a01b03928316602483015260448201949094526080606482015294931692602092909185906109d19060848301906106bb565b039483816000978189895af1869181610a7b575b50610a46575050503d600014610a3d573d6109ff816107b5565b90610a0d6040519283610793565b81528093823d92013e5b82519283610a3857604051633250574960e11b815260048101849052602490fd5b019050fd5b60609250610a17565b919450915063ffffffff60e01b1603610a6357503880808061097f565b60249060405190633250574960e11b82526004820152fd5b9091508481813d8311610ab8575b610a938183610793565b81010312610ab457516001600160e01b031981168103610ab45790386109e5565b8680fd5b503d610a89565b6000818152600260205260409020546001600160a01b0316908115610ae2575090565b60249060405190637e27328960e01b82526004820152fdfea264697066735822122044235653b73457193b8d7b6102b48056d30e5fbb4bd4af7fe5e9f92b11d1c41c64736f6c63430008190033",
|
|
447
447
|
"linkReferences": {},
|
|
448
448
|
"deployedLinkReferences": {}
|
|
449
449
|
}
|
|
@@ -55,68 +55,35 @@ export const ERC1155Abi = ERC1155Artifact.abi;
|
|
|
55
55
|
// Make sure ContractName in ./types includes all of these keys.
|
|
56
56
|
export const ADDRESSES: AddressBook = {
|
|
57
57
|
// LiqETH contracts
|
|
58
|
-
LiqEthAuthority: "
|
|
59
|
-
BeaconState: "
|
|
60
|
-
WithdrawalQueue: "
|
|
61
|
-
LiqEthToken: "
|
|
62
|
-
Accounting: "
|
|
63
|
-
DepositManager: "
|
|
64
|
-
WithdrawalVault: "
|
|
65
|
-
StakingModule: "
|
|
66
|
-
YieldOracle: "
|
|
58
|
+
LiqEthAuthority: "0x3Eb66Bb91F7a022FbABc1619Cb6acce7025Bc41F",
|
|
59
|
+
BeaconState: "0x08F879c6D0964E0A17bF688Af23168f654DF372e",
|
|
60
|
+
WithdrawalQueue: "0x74aDeD940369baDDb0F36426F23B08499e45Fe18",
|
|
61
|
+
LiqEthToken: "0x8C974517D038e2e3b8a1da7b1A026bC8132A4b2e",
|
|
62
|
+
Accounting: "0x766CE996B8132b927988c5b2ECAE8108fB1a9307",
|
|
63
|
+
DepositManager: "0xEd391dB5DB11B5eDBE08e69A51D16e84293C09a3",
|
|
64
|
+
WithdrawalVault: "0xbaBc0D5997283ab9886696A0dEaB8A8093436b48",
|
|
65
|
+
StakingModule: "0x4998fBb6Ca5Ee3Db6c339e2962A34791Af643fEa",
|
|
66
|
+
YieldOracle: "0x61Fe311C57dd9a38Fb7B0c5A8ec521452dB25378",
|
|
67
67
|
|
|
68
68
|
//Outpost contracts
|
|
69
|
-
OutpostManagerAuthority: "
|
|
70
|
-
iodata: "
|
|
71
|
-
Base58: "
|
|
72
|
-
sysio_merkle: "
|
|
73
|
-
ReceiptNFT: "
|
|
74
|
-
EthUsdPriceConsumer: "
|
|
75
|
-
Pool: "
|
|
76
|
-
OutpostManager: "
|
|
77
|
-
sysio_write: "
|
|
78
|
-
Pretoken: "
|
|
79
|
-
BAR: "
|
|
80
|
-
OPPCommon: "
|
|
81
|
-
OPP: "
|
|
82
|
-
Depositor: "
|
|
83
|
-
OPPInbound: "
|
|
69
|
+
OutpostManagerAuthority: "0x3B8705Ba1195AF632b3bd9E46F19348BC828FA3D",
|
|
70
|
+
iodata: "0x4aCABbC74a1cA9B0058d9ADAa0E00Af0f4f73212",
|
|
71
|
+
Base58: "0x1241F36ff30065deD52d51f0d6524EF971259A12",
|
|
72
|
+
sysio_merkle: "0x58ca9b5515266Fd6bF94D5F1268C505b2eC9679c",
|
|
73
|
+
ReceiptNFT: "0x03d6bD46cA9F54B8F8bbA21CfAfe717b36cB8593",
|
|
74
|
+
EthUsdPriceConsumer: "0xdC2DD993A13b3DD6D255B52285625694bd967c9A",
|
|
75
|
+
Pool: "0xd4742757AA61B1Fd3Fcd87980D7D460B12Cd9275",
|
|
76
|
+
OutpostManager: "0x38ec2B56cBCeCaFFe28b535517de1a102C3D74E3",
|
|
77
|
+
sysio_write: "0x0Ec4C1BaB772958aa3Db27459643bfbE7d92E305",
|
|
78
|
+
Pretoken: "0x8c97a51A71640fa411DEfab8feC3401eFfd1a2E4",
|
|
79
|
+
BAR: "0xbAFac13ffd3Aa9aEabaaeb6e4C2cF3dFf3479DC0",
|
|
80
|
+
OPPCommon: "0x12283a6d4E6cE4A0e8AdB319Fc161c7F4f91EA8F",
|
|
81
|
+
OPP: "0x87CE3Fe2CDca39C04aa2c14bbF1E1d9DB6358C4A",
|
|
82
|
+
Depositor: "0x5351B30EA4b75bD9be9Fc0048e88F675f7b3Ac2b",
|
|
83
|
+
OPPInbound: "0x0B1f7FB1c7f01A9cf490a1387E1E100F2bEA6C6d",
|
|
84
84
|
MockAggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF",
|
|
85
|
-
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
// Latest
|
|
89
|
-
// LiqETH contracts
|
|
90
|
-
// LiqEthAuthority: "0x612536e386801b337363Cfa4CC0a7C33Ad588136",
|
|
91
|
-
// BeaconState: "0x48462108c8254568e1d2D4fE3178579d9298ceC4",
|
|
92
|
-
// WithdrawalQueue: "0x49aeFA8B860d908476724e00b48fDa7529f63DbA",
|
|
93
|
-
// LiqEthToken: "0x1e0fb59F0C1Db95fD8f8743B1B3e709CdccF4002",
|
|
94
|
-
// Accounting: "0x679A76d462B9A499F8D23Cb3Fa6CbeB81B5779b9",
|
|
95
|
-
// DepositManager: "0xe63a8f755195D019Db893BF0542A2533895ec927",
|
|
96
|
-
// WithdrawalVault: "0x5C9C8d9Ec8F1Cb64D231b301712405c5E14C175d",
|
|
97
|
-
// StakingModule: "0x5dB271F09f840b49E5E77A3B8fDA30F56A66af20",
|
|
98
|
-
// YieldOracle: "0x323022827e4922a14f30eF8Ad83A393628e0Ac34",
|
|
99
|
-
|
|
100
|
-
// //Outpost contracts
|
|
101
|
-
// OutpostManagerAuthority: "0x5047Cf5F7bae2d5737B29AAbE910ceE0F3344059",
|
|
102
|
-
// iodata: "0x82A24E7240DaBaAD49A157dB2a203Edb6486d81f",
|
|
103
|
-
// Base58: "0x97aE9B0A8D1678fC73EF7B67539236A85284E2FF",
|
|
104
|
-
// sysio_merkle: "0x3A30901fC4dD25E75dcF9c790b620183aF0Bc3D5",
|
|
105
|
-
// ReceiptNFT: "0xee4f7075B8ac06bb709075D5963C8e012Ef74cc1",
|
|
106
|
-
// EthUsdPriceConsumer: "0x202719423E364aB0C8b4005ee25A20c4A5AB28DC",
|
|
107
|
-
// Pool: "0x8fB1a92c4107Ac1072f51Fac3617A5494Eb71573",
|
|
108
|
-
// OutpostManager: "0x88760aD68a557Aa4FeCde82dA9B024948e7B6074",
|
|
109
|
-
// sysio_write: "0x7485Bb3AA184D33dC54149bBE0BEd548791a6D8f",
|
|
110
|
-
// Pretoken: "0x474B3944e8b9C82264434f394d2367f046869Adc",
|
|
111
|
-
// BAR: "0x779Bb699A0ad10EB8A13d177e594B1268f72C602",
|
|
112
|
-
// OPPCommon: "0x14280b40a8a1F037dDBf9bddf8b78Bc4f11276BA",
|
|
113
|
-
// OPP: "0xBae03C8bb8f557dc48AE9D6F9032d503819B11a7",
|
|
114
|
-
// Depositor: "0x66f41027F9642384c73ce9C8944340a1Af497982",
|
|
115
|
-
// OPPInbound: "0x2AA0833Fc72314faD52a2dA932973abB8491E96F",
|
|
116
|
-
// MockAggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF",
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
87
|
export type Contracts<T extends string = ContractName> = Record<T, ContractConfig>;
|
|
121
88
|
|
|
122
89
|
export type ContractConfig = {
|
|
@@ -142,7 +142,10 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
142
142
|
const buyer = await this.signer!.getAddress();
|
|
143
143
|
|
|
144
144
|
// ! Hoodi only - check if the mock aggregator price is stale, and if so, update it before submitting the buy request
|
|
145
|
-
await this.
|
|
145
|
+
const network = await this.provider.getNetwork();
|
|
146
|
+
const chainId = network.chainId;
|
|
147
|
+
const allowedTestChains = new Set([560048]);
|
|
148
|
+
if (allowedTestChains.has(chainId)) await this.updateMockAggregatorPrice();
|
|
146
149
|
|
|
147
150
|
let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
|
|
148
151
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
@@ -368,7 +371,12 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
368
371
|
|
|
369
372
|
// fetch price and timestamp from aggregator
|
|
370
373
|
const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
|
|
371
|
-
|
|
374
|
+
//originally fetched ethPrice from aggregator - pulling from EthUsdPriceConsumer instead - this is where the actual price gets pulled from when purchasing pretokens.
|
|
375
|
+
// let ethPriceUsd: bigint = BigInt(answer.toString());)
|
|
376
|
+
|
|
377
|
+
let ethPriceUsdBn = await this.contract.EthUsdPriceConsumer.getPrice18Decimals();
|
|
378
|
+
let ethPriceUsd: bigint = BigInt(ethPriceUsdBn.toString()) / BigInt(1e10);
|
|
379
|
+
|
|
372
380
|
let nativePriceTimestamp: number = Number(updatedAt);
|
|
373
381
|
|
|
374
382
|
const initialTrancheSupply = BigInt(INITIAL_TRANCHE_SUPPLY) * BigInt(1e8);
|
|
@@ -410,10 +418,11 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
410
418
|
* @param options.safetyMultiplier Additional safety multiplier on top of txCount (default 1.5x)
|
|
411
419
|
* @param options.minBufferWei Optional override minimum buffer (defaults ~0.002 ETH)
|
|
412
420
|
*/
|
|
413
|
-
async
|
|
421
|
+
async getDepositBuffer(options?: {
|
|
414
422
|
txCount?: number;
|
|
415
423
|
safetyMultiplier?: number;
|
|
416
424
|
minBufferWei?: bigint;
|
|
425
|
+
balanceOverrideLamports?: bigint;
|
|
417
426
|
}): Promise<bigint> {
|
|
418
427
|
this.ensureUser();
|
|
419
428
|
|
|
@@ -482,6 +482,46 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
482
482
|
// READ-ONLY Public Methods
|
|
483
483
|
// ---------------------------------------------------------------------
|
|
484
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Unified, chain-agnostic tranche snapshot for Solana.
|
|
487
|
+
*
|
|
488
|
+
* Uses:
|
|
489
|
+
* - liqsol_core.globalState (currentIndex, totalShares, etc.)
|
|
490
|
+
* - liqsol_core.trancheState (price, supply, total sold, etc.)
|
|
491
|
+
* - PriceHistory/Chainlink SOL/USD via TokenClient.getSolPriceUsdSafe()
|
|
492
|
+
*
|
|
493
|
+
* This is READ-ONLY and works even with no connected wallet.
|
|
494
|
+
*/
|
|
495
|
+
async getTrancheSnapshot(options?: {
|
|
496
|
+
chainID?: ChainID;
|
|
497
|
+
windowBefore?: number;
|
|
498
|
+
windowAfter?: number;
|
|
499
|
+
}): Promise<TrancheSnapshot> {
|
|
500
|
+
const {
|
|
501
|
+
chainID = SolChainID.WireTestnet,
|
|
502
|
+
windowBefore,
|
|
503
|
+
windowAfter,
|
|
504
|
+
} = options ?? {};
|
|
505
|
+
|
|
506
|
+
const [globalState, trancheState] = await Promise.all([
|
|
507
|
+
this.tokenClient.fetchGlobalState(),
|
|
508
|
+
this.tokenClient.fetchTrancheState(),
|
|
509
|
+
]);
|
|
510
|
+
|
|
511
|
+
const { price: solPriceUsd, timestamp } =
|
|
512
|
+
await this.tokenClient.getSolPriceUsdSafe();
|
|
513
|
+
|
|
514
|
+
return buildSolanaTrancheSnapshot({
|
|
515
|
+
chainID,
|
|
516
|
+
globalState,
|
|
517
|
+
trancheState,
|
|
518
|
+
solPriceUsd,
|
|
519
|
+
nativePriceTimestamp: timestamp,
|
|
520
|
+
ladderWindowBefore: windowBefore,
|
|
521
|
+
ladderWindowAfter: windowAfter,
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
|
|
485
525
|
/**
|
|
486
526
|
* Returns the system APY (percent) for Solana,
|
|
487
527
|
* using compound interest per epoch and a
|
|
@@ -633,112 +673,145 @@ export class SolanaStakingClient implements IStakingClient {
|
|
|
633
673
|
}
|
|
634
674
|
|
|
635
675
|
/**
|
|
636
|
-
*
|
|
676
|
+
* Compute a conservative "deposit buffer" in lamports that should be left
|
|
677
|
+
* in the wallet so that a MAX deposit (balance - buffer) will succeed.
|
|
637
678
|
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* - PriceHistory/Chainlink SOL/USD via TokenClient.getSolPriceUsdSafe()
|
|
679
|
+
* It accounts for:
|
|
680
|
+
* - Runtime tx fees (via a dummy self-transfer)
|
|
681
|
+
* - Protocol deposit fee (via getDepositFee(amount))
|
|
642
682
|
*
|
|
643
|
-
*
|
|
683
|
+
* Intended UI usage:
|
|
684
|
+
* const buffer = await client.getDepositBuffer();
|
|
685
|
+
* const balance = portfolio.native.amount;
|
|
686
|
+
* const maxDeposit = balance > buffer ? balance - buffer : BigInt(0);
|
|
644
687
|
*/
|
|
645
|
-
async
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
windowBefore,
|
|
653
|
-
windowAfter,
|
|
654
|
-
} = options ?? {};
|
|
688
|
+
async getDepositBuffer(options?: {
|
|
689
|
+
txCount?: number; // how many txs to cover in gas buffer (default 2)
|
|
690
|
+
safetyMultiplier?: number; // safety multiplier on per-tx fee (default 3x)
|
|
691
|
+
minBufferLamports?: bigint; // minimum gas buffer (default ~0.01 SOL)
|
|
692
|
+
balanceOverrideLamports?: bigint; // for tests/custom callers
|
|
693
|
+
}): Promise<bigint> {
|
|
694
|
+
this.ensureUser();
|
|
655
695
|
|
|
656
|
-
const
|
|
657
|
-
this.tokenClient.fetchGlobalState(),
|
|
658
|
-
this.tokenClient.fetchTrancheState(),
|
|
659
|
-
]);
|
|
696
|
+
const payer = this.solPubKey;
|
|
660
697
|
|
|
661
|
-
|
|
662
|
-
|
|
698
|
+
// -------------------------------------------------------------
|
|
699
|
+
// 1) Current wallet balance
|
|
700
|
+
// -------------------------------------------------------------
|
|
701
|
+
const balanceLamports: bigint =
|
|
702
|
+
options?.balanceOverrideLamports ??
|
|
703
|
+
BigInt(await this.connection.getBalance(payer, commitment));
|
|
663
704
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
trancheState,
|
|
668
|
-
solPriceUsd,
|
|
669
|
-
nativePriceTimestamp: timestamp,
|
|
670
|
-
ladderWindowBefore: windowBefore,
|
|
671
|
-
ladderWindowAfter: windowAfter,
|
|
672
|
-
});
|
|
673
|
-
}
|
|
705
|
+
if (balanceLamports <= BigInt(0)) {
|
|
706
|
+
return BigInt(0);
|
|
707
|
+
}
|
|
674
708
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
minBufferLamports?: bigint;
|
|
694
|
-
}): Promise<bigint> {
|
|
695
|
-
this.ensureUser();
|
|
709
|
+
// -------------------------------------------------------------
|
|
710
|
+
// 2) Estimate gas buffer via dummy self-transfer
|
|
711
|
+
// -------------------------------------------------------------
|
|
712
|
+
let gasBuffer = BigInt(0);
|
|
713
|
+
|
|
714
|
+
try {
|
|
715
|
+
const dummyIx = SystemProgram.transfer({
|
|
716
|
+
fromPubkey: payer,
|
|
717
|
+
toPubkey: payer,
|
|
718
|
+
lamports: 0,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
const tx = new Transaction().add(dummyIx);
|
|
722
|
+
const { blockhash } = await this.connection.getLatestBlockhash(
|
|
723
|
+
commitment,
|
|
724
|
+
);
|
|
725
|
+
tx.recentBlockhash = blockhash;
|
|
726
|
+
tx.feePayer = payer;
|
|
696
727
|
|
|
697
|
-
|
|
728
|
+
const message = tx.compileMessage();
|
|
729
|
+
const feeInfo = await this.connection.getFeeForMessage(
|
|
730
|
+
message,
|
|
731
|
+
commitment,
|
|
732
|
+
);
|
|
698
733
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
fromPubkey: payer,
|
|
702
|
-
toPubkey: payer,
|
|
703
|
-
lamports: 0,
|
|
704
|
-
});
|
|
734
|
+
// Fallback to a conservative default if RPC doesn't give a value.
|
|
735
|
+
const singleTxFeeLamports = BigInt(feeInfo.value ?? 5000);
|
|
705
736
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
tx.feePayer = payer;
|
|
737
|
+
const txCount = BigInt(options?.txCount ?? 2);
|
|
738
|
+
const safetyMultiplier = options?.safetyMultiplier ?? 3;
|
|
739
|
+
const safetyScaled = BigInt(Math.round(safetyMultiplier * 100)); // e.g. 300
|
|
710
740
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
741
|
+
let buf =
|
|
742
|
+
(singleTxFeeLamports * txCount * safetyScaled) /
|
|
743
|
+
BigInt(100);
|
|
714
744
|
|
|
715
|
-
|
|
716
|
-
|
|
745
|
+
const defaultMinBufferLamports = BigInt(10_000_000); // ~0.01 SOL
|
|
746
|
+
const minBufferLamports =
|
|
747
|
+
options?.minBufferLamports ?? defaultMinBufferLamports;
|
|
717
748
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
749
|
+
if (buf < minBufferLamports) {
|
|
750
|
+
buf = minBufferLamports;
|
|
751
|
+
}
|
|
721
752
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
753
|
+
gasBuffer = buf;
|
|
754
|
+
} catch {
|
|
755
|
+
// If fee estimation fails, fall back to zero gas buffer
|
|
756
|
+
// (we will still leave room for protocol fee below).
|
|
757
|
+
gasBuffer = BigInt(0);
|
|
758
|
+
}
|
|
725
759
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
BigInt(100);
|
|
760
|
+
// If fees alone eat the whole balance, just keep everything as buffer.
|
|
761
|
+
if (balanceLamports <= gasBuffer) {
|
|
762
|
+
return balanceLamports;
|
|
763
|
+
}
|
|
731
764
|
|
|
732
|
-
|
|
733
|
-
const defaultMinBufferLamports = BigInt(10_000_000); // 0.01 SOL (1e9 / 100)
|
|
734
|
-
const minBufferLamports =
|
|
735
|
-
options?.minBufferLamports ?? defaultMinBufferLamports;
|
|
765
|
+
const spendable = balanceLamports - gasBuffer;
|
|
736
766
|
|
|
737
|
-
|
|
738
|
-
|
|
767
|
+
// -------------------------------------------------------------
|
|
768
|
+
// 3) If we can't compute deposit fee, buffer == gasBuffer
|
|
769
|
+
// -------------------------------------------------------------
|
|
770
|
+
if (typeof this.getDepositFee !== 'function') {
|
|
771
|
+
return gasBuffer;
|
|
739
772
|
}
|
|
740
773
|
|
|
741
|
-
|
|
774
|
+
// -------------------------------------------------------------
|
|
775
|
+
// 4) Binary search for max principal p such that:
|
|
776
|
+
// p + fee(p) <= spendable
|
|
777
|
+
// Then buffer = balance - pEffective.
|
|
778
|
+
// -------------------------------------------------------------
|
|
779
|
+
let lo = BigInt(0);
|
|
780
|
+
let hi = spendable;
|
|
781
|
+
|
|
782
|
+
for (let i = 0; i < 20 && hi - lo > BigInt(1); i++) {
|
|
783
|
+
const mid = (lo + hi) / BigInt(2);
|
|
784
|
+
|
|
785
|
+
let fee: bigint;
|
|
786
|
+
try {
|
|
787
|
+
fee = await this.getDepositFee(mid);
|
|
788
|
+
} catch {
|
|
789
|
+
// If fee lookup fails mid-search, fall back to gas-only buffer.
|
|
790
|
+
return gasBuffer;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (mid + fee <= spendable) {
|
|
794
|
+
lo = mid; // mid is affordable → try bigger
|
|
795
|
+
} else {
|
|
796
|
+
hi = mid; // mid too big → go smaller
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// Tiny safety haircut to avoid off-by-one lamport issues.
|
|
801
|
+
const fudge = BigInt(1_000); // ≈ 0.000001 SOL
|
|
802
|
+
let effectivePrincipal =
|
|
803
|
+
lo > fudge ? lo - fudge : lo;
|
|
804
|
+
|
|
805
|
+
if (effectivePrincipal < BigInt(0)) {
|
|
806
|
+
effectivePrincipal = BigInt(0);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const buffer = balanceLamports > effectivePrincipal
|
|
810
|
+
? balanceLamports - effectivePrincipal
|
|
811
|
+
: balanceLamports;
|
|
812
|
+
|
|
813
|
+
// Ensure we never *under*-reserve gas
|
|
814
|
+
return buffer < gasBuffer ? gasBuffer : buffer;
|
|
742
815
|
}
|
|
743
816
|
|
|
744
817
|
// ---------------------------------------------------------------------
|
package/src/staker.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -26,13 +26,6 @@ export interface IStakingClient {
|
|
|
26
26
|
// Estimated total APY for staking yeild
|
|
27
27
|
getSystemAPY(): Promise<number>;
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Protocol fee charged for deposit from Native to LIQ
|
|
31
|
-
* in Solana: amount in lamports
|
|
32
|
-
* in Ethereum: amount in wei
|
|
33
|
-
*/
|
|
34
|
-
getDepositFee(amount: bigint): Promise<bigint>;
|
|
35
|
-
|
|
36
29
|
/**
|
|
37
30
|
* Program-level prelaunch WIRE/tranche snapshot for this chain.
|
|
38
31
|
*
|
|
@@ -46,15 +39,23 @@ export interface IStakingClient {
|
|
|
46
39
|
windowAfter?: number;
|
|
47
40
|
}): Promise<TrancheSnapshot | null>;
|
|
48
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Protocol fee charged for deposit from Native to LIQ
|
|
44
|
+
* in Solana: amount in lamports
|
|
45
|
+
* in Ethereum: amount in wei
|
|
46
|
+
*/
|
|
47
|
+
getDepositFee(amount: bigint): Promise<bigint>;
|
|
48
|
+
|
|
49
49
|
/**
|
|
50
50
|
* Estimate a conservative ETH(wei) / SOL(lamports) buffer to leave in the wallet
|
|
51
51
|
* so the user can pay fees for the current deposit and at least one
|
|
52
52
|
* more transaction, plus a bit extra for future interactions.
|
|
53
53
|
*/
|
|
54
|
-
|
|
55
|
-
txCount?: number;
|
|
56
|
-
safetyMultiplier?: number;
|
|
57
|
-
|
|
54
|
+
getDepositBuffer(options?: {
|
|
55
|
+
txCount?: number; // how many txs to cover in gas buffer (default 2)
|
|
56
|
+
safetyMultiplier?: number; // safety multiplier on per-tx fee (default 3x)
|
|
57
|
+
minBufferLamports?: bigint; // minimum gas buffer (default ~0.01 SOL)
|
|
58
|
+
balanceOverrideLamports?: bigint; // for tests/custom callers
|
|
58
59
|
}): Promise<bigint>
|
|
59
60
|
}
|
|
60
61
|
|