Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

create a DAOLama get methods #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions abi/get_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error)
"get_params": {DecodeGetParams_WhalesNominatorResult},
"get_plugin_list": {DecodeGetPluginListResult},
"get_pool_address": {DecodeGetPoolAddress_StonfiResult},
"get_pool_data": {DecodeGetPoolData_StonfiResult, DecodeGetPoolData_StonfiV2Result, DecodeGetPoolData_TfResult},
"get_pool_data": {DecodeGetPoolData_DaolamaResult, DecodeGetPoolData_StonfiResult, DecodeGetPoolData_StonfiV2Result, DecodeGetPoolData_TfResult},
"get_pool_full_data": {DecodeGetPoolFullDataResult},
"get_pool_status": {DecodeGetPoolStatusResult},
"get_position_manager_contract_data": {DecodeGetPositionManagerContractData_StormResult},
Expand Down Expand Up @@ -257,6 +257,7 @@ var resultTypes = []interface{}{
&GetParams_WhalesNominatorResult{},
&GetPluginListResult{},
&GetPoolAddress_StonfiResult{},
&GetPoolData_DaolamaResult{},
&GetPoolData_StonfiResult{},
&GetPoolData_StonfiV2Result{},
&GetPoolData_TfResult{},
Expand Down Expand Up @@ -2323,6 +2324,14 @@ func DecodeGetPoolAddress_StonfiResult(stack tlb.VmStack) (resultType string, re
return "GetPoolAddress_StonfiResult", result, err
}

type GetPoolData_DaolamaResult struct {
Halted bool
Balance uint64
Borrowed uint64
LpTokenBalance uint64
FeeCollected uint64
}

type GetPoolData_StonfiResult struct {
Reserve0 tlb.Int257
Reserve1 tlb.Int257
Expand Down Expand Up @@ -2383,7 +2392,7 @@ func GetPoolData(ctx context.Context, executor Executor, reqAccountID ton.Accoun
if errCode != 0 && errCode != 1 {
return "", nil, fmt.Errorf("method execution failed with code: %v", errCode)
}
for _, f := range []func(tlb.VmStack) (string, any, error){DecodeGetPoolData_StonfiResult, DecodeGetPoolData_StonfiV2Result, DecodeGetPoolData_TfResult} {
for _, f := range []func(tlb.VmStack) (string, any, error){DecodeGetPoolData_DaolamaResult, DecodeGetPoolData_StonfiResult, DecodeGetPoolData_StonfiV2Result, DecodeGetPoolData_TfResult} {
s, r, err := f(stack)
if err == nil {
return s, r, nil
Expand All @@ -2392,6 +2401,15 @@ func GetPoolData(ctx context.Context, executor Executor, reqAccountID ton.Accoun
return "", nil, fmt.Errorf("can not decode outputs")
}

func DecodeGetPoolData_DaolamaResult(stack tlb.VmStack) (resultType string, resultAny any, err error) {
if len(stack) != 5 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") {
return "", nil, fmt.Errorf("invalid stack format")
}
var result GetPoolData_DaolamaResult
err = stack.Unmarshal(&result)
return "GetPoolData_DaolamaResult", result, err
}

func DecodeGetPoolData_StonfiResult(stack tlb.VmStack) (resultType string, resultAny any, err error) {
if len(stack) != 10 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkSlice") || (stack[3].SumType != "VmStkSlice") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (stack[5].SumType != "VmStkTinyInt" && stack[5].SumType != "VmStkInt") || (stack[6].SumType != "VmStkTinyInt" && stack[6].SumType != "VmStkInt") || (stack[7].SumType != "VmStkSlice") || (stack[8].SumType != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkTinyInt" && stack[9].SumType != "VmStkInt") {
return "", nil, fmt.Errorf("invalid stack format")
Expand Down
16 changes: 16 additions & 0 deletions abi/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

const (
IUnknown ContractInterface = iota
DaolamaVault
DedustFactory
DedustLiquidityDeposit
DedustPool
Expand Down Expand Up @@ -84,6 +85,8 @@ const (

func (c ContractInterface) String() string {
switch c {
case DaolamaVault:
return "daolama_vault"
case DedustFactory:
return "dedust_factory"
case DedustLiquidityDeposit:
Expand Down Expand Up @@ -235,6 +238,8 @@ func (c ContractInterface) String() string {

func ContractInterfaceFromString(s string) ContractInterface {
switch s {
case "daolama_vault":
return DaolamaVault
case "dedust_factory":
return DedustFactory
case "dedust_liquidity_deposit ":
Expand Down Expand Up @@ -732,6 +737,12 @@ var methodInvocationOrder = []MethodDescription{
}

var contractInterfacesOrder = []InterfaceDescription{
{
Name: DaolamaVault,
Results: []string{
"GetPoolDataResult",
},
},
{
Name: DedustLiquidityDeposit,
Results: []string{
Expand Down Expand Up @@ -1266,6 +1277,11 @@ var knownContracts = map[ton.Bits256]knownContractDescription{

func (c ContractInterface) IntMsgs() []msgDecoderFunc {
switch c {
case DaolamaVault:
return []msgDecoderFunc{
decodeFuncDaolamaVaultSupplyMsgBody,
decodeFuncDaolamaVaultWithdrawMsgBody,
}
case DedustFactory:
return []msgDecoderFunc{
decodeFuncDedustCreateVaultMsgBody,
Expand Down
2 changes: 2 additions & 0 deletions abi/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ The list below contains the supported message operations, their names and opcode
| ChannelCooperativeCommit| 0x79a126ef |
| CloseStorageContract| 0x79f937ea |
| Credit| 0x1690c604 |
| DaolamaVaultSupply| 0x5c11ada9 |
| DaolamaVaultWithdraw| 0x7bdd97de |
| DedustCancelDeposit| 0x166cedee |
| DedustCreateVault| 0x21cfe02b |
| DedustCreateVolatilePool| 0x97d51f2f |
Expand Down
30 changes: 28 additions & 2 deletions abi/messages_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ var (
decodeFuncJettonBurnMsgBody = decodeMsg(tlb.Tag{Val: 0x595f07bc, Len: 32}, JettonBurnMsgOp, JettonBurnMsgBody{})
// 0x5be57626
decodeFuncHipoFinanceProxyTokensMintedMsgBody = decodeMsg(tlb.Tag{Val: 0x5be57626, Len: 32}, HipoFinanceProxyTokensMintedMsgOp, HipoFinanceProxyTokensMintedMsgBody{})
// 0x5c11ada9
decodeFuncDaolamaVaultSupplyMsgBody = decodeMsg(tlb.Tag{Val: 0x5c11ada9, Len: 32}, DaolamaVaultSupplyMsgOp, DaolamaVaultSupplyMsgBody{})
// 0x5d1b17b8
decodeFuncStormUpdatePositionWithStopLossMsgBody = decodeMsg(tlb.Tag{Val: 0x5d1b17b8, Len: 32}, StormUpdatePositionWithStopLossMsgOp, StormUpdatePositionWithStopLossMsgBody{})
// 0x5dd66579
Expand Down Expand Up @@ -240,6 +242,8 @@ var (
// 0x7bcd1fef
decodeFuncWhalesNominatorsDepositMsgBody = decodeMsg(tlb.Tag{Val: 0x7bcd1fef, Len: 32}, WhalesNominatorsDepositMsgOp, WhalesNominatorsDepositMsgBody{})
// 0x7bdd97de
decodeFuncDaolamaVaultWithdrawMsgBody = decodeMsg(tlb.Tag{Val: 0x7bdd97de, Len: 32}, DaolamaVaultWithdrawMsgOp, DaolamaVaultWithdrawMsgBody{})
// 0x7bdd97de
decodeFuncJettonBurnNotificationMsgBody = decodeMsg(tlb.Tag{Val: 0x7bdd97de, Len: 32}, JettonBurnNotificationMsgOp, JettonBurnNotificationMsgBody{})
// 0x82609bf6
decodeFuncMultisigApproveAcceptedMsgBody = decodeMsg(tlb.Tag{Val: 0x82609bf6, Len: 32}, MultisigApproveAcceptedMsgOp, MultisigApproveAcceptedMsgBody{})
Expand Down Expand Up @@ -616,6 +620,9 @@ var opcodedMsgInDecodeFunctions = map[uint32]msgDecoderFunc{
// 0x5be57626
HipoFinanceProxyTokensMintedMsgOpCode: decodeFuncHipoFinanceProxyTokensMintedMsgBody,

// 0x5c11ada9
DaolamaVaultSupplyMsgOpCode: decodeFuncDaolamaVaultSupplyMsgBody,

// 0x5d1b17b8
StormUpdatePositionWithStopLossMsgOpCode: decodeFuncStormUpdatePositionWithStopLossMsgBody,

Expand Down Expand Up @@ -727,8 +734,12 @@ var opcodedMsgInDecodeFunctions = map[uint32]msgDecoderFunc{
// 0x7bcd1fef
WhalesNominatorsDepositMsgOpCode: decodeFuncWhalesNominatorsDepositMsgBody,

// 0x7bdd97de
JettonBurnNotificationMsgOpCode: decodeFuncJettonBurnNotificationMsgBody,
//DaolamaVaultWithdraw, JettonBurnNotification,
0x7bdd97de: decodeMultipleMsgs([]msgDecoderFunc{
decodeFuncDaolamaVaultWithdrawMsgBody,
decodeFuncJettonBurnNotificationMsgBody},
"0x7bdd97de",
),

// 0x82609bf6
MultisigApproveAcceptedMsgOpCode: decodeFuncMultisigApproveAcceptedMsgBody,
Expand Down Expand Up @@ -1009,6 +1020,7 @@ const (
TonstakeControllerReturnAvailableFundsMsgOp MsgOpName = "TonstakeControllerReturnAvailableFunds"
JettonBurnMsgOp MsgOpName = "JettonBurn"
HipoFinanceProxyTokensMintedMsgOp MsgOpName = "HipoFinanceProxyTokensMinted"
DaolamaVaultSupplyMsgOp MsgOpName = "DaolamaVaultSupply"
StormUpdatePositionWithStopLossMsgOp MsgOpName = "StormUpdatePositionWithStopLoss"
StormAddExecutorAmountMsgOp MsgOpName = "StormAddExecutorAmount"
TonstakePoolSetRolesMsgOp MsgOpName = "TonstakePoolSetRoles"
Expand Down Expand Up @@ -1046,6 +1058,7 @@ const (
AcceptStorageContractMsgOp MsgOpName = "AcceptStorageContract"
ApproveMsgOp MsgOpName = "Approve"
WhalesNominatorsDepositMsgOp MsgOpName = "WhalesNominatorsDeposit"
DaolamaVaultWithdrawMsgOp MsgOpName = "DaolamaVaultWithdraw"
JettonBurnNotificationMsgOp MsgOpName = "JettonBurnNotification"
MultisigApproveAcceptedMsgOp MsgOpName = "MultisigApproveAccepted"
StormAddReferralAmountMsgOp MsgOpName = "StormAddReferralAmount"
Expand Down Expand Up @@ -1195,6 +1208,7 @@ const (
TonstakeControllerReturnAvailableFundsMsgOpCode MsgOpCode = 0x55c26cd5
JettonBurnMsgOpCode MsgOpCode = 0x595f07bc
HipoFinanceProxyTokensMintedMsgOpCode MsgOpCode = 0x5be57626
DaolamaVaultSupplyMsgOpCode MsgOpCode = 0x5c11ada9
StormUpdatePositionWithStopLossMsgOpCode MsgOpCode = 0x5d1b17b8
StormAddExecutorAmountMsgOpCode MsgOpCode = 0x5dd66579
TonstakePoolSetRolesMsgOpCode MsgOpCode = 0x5e517f36
Expand Down Expand Up @@ -1232,6 +1246,7 @@ const (
AcceptStorageContractMsgOpCode MsgOpCode = 0x7a361688
ApproveMsgOpCode MsgOpCode = 0x7b4b42e6
WhalesNominatorsDepositMsgOpCode MsgOpCode = 0x7bcd1fef
DaolamaVaultWithdrawMsgOpCode MsgOpCode = 0x7bdd97de
JettonBurnNotificationMsgOpCode MsgOpCode = 0x7bdd97de
MultisigApproveAcceptedMsgOpCode MsgOpCode = 0x82609bf6
StormAddReferralAmountMsgOpCode MsgOpCode = 0x84dced7a
Expand Down Expand Up @@ -1809,6 +1824,10 @@ type HipoFinanceProxyTokensMintedMsgBody struct {
RoundSince uint32
}

type DaolamaVaultSupplyMsgBody struct {
Amount tlb.Grams
}

type StormUpdatePositionWithStopLossMsgBody struct {
Direction tlb.Uint1
StopTriggerPrice tlb.Grams
Expand Down Expand Up @@ -2068,6 +2087,11 @@ type WhalesNominatorsDepositMsgBody struct {
Gas tlb.Grams
}

type DaolamaVaultWithdrawMsgBody struct {
JettonAmount tlb.Grams
UserAddress tlb.MsgAddress
}

type JettonBurnNotificationMsgBody struct {
QueryId uint64
Amount tlb.VarUInteger16
Expand Down Expand Up @@ -2539,6 +2563,7 @@ var KnownMsgInTypes = map[string]any{
TonstakeControllerReturnAvailableFundsMsgOp: TonstakeControllerReturnAvailableFundsMsgBody{},
JettonBurnMsgOp: JettonBurnMsgBody{},
HipoFinanceProxyTokensMintedMsgOp: HipoFinanceProxyTokensMintedMsgBody{},
DaolamaVaultSupplyMsgOp: DaolamaVaultSupplyMsgBody{},
StormUpdatePositionWithStopLossMsgOp: StormUpdatePositionWithStopLossMsgBody{},
StormAddExecutorAmountMsgOp: StormAddExecutorAmountMsgBody{},
TonstakePoolSetRolesMsgOp: TonstakePoolSetRolesMsgBody{},
Expand Down Expand Up @@ -2576,6 +2601,7 @@ var KnownMsgInTypes = map[string]any{
AcceptStorageContractMsgOp: AcceptStorageContractMsgBody{},
ApproveMsgOp: ApproveMsgBody{},
WhalesNominatorsDepositMsgOp: WhalesNominatorsDepositMsgBody{},
DaolamaVaultWithdrawMsgOp: DaolamaVaultWithdrawMsgBody{},
JettonBurnNotificationMsgOp: JettonBurnNotificationMsgBody{},
MultisigApproveAcceptedMsgOp: MultisigApproveAcceptedMsgBody{},
StormAddReferralAmountMsgOp: StormAddReferralAmountMsgBody{},
Expand Down
28 changes: 28 additions & 0 deletions abi/schemas/daolama.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<abi>
<interface name="daolama_vault">
<msg_in>
<internal name="daolama_vault_supply"/>
<internal name="daolama_vault_withdraw"/>
</msg_in>

<get_method name="get_pool_data"/>
</interface>

<internal name="daolama_vault_supply">
supply#5c11ada9 amount:Coins = InternalMsgBody;
</internal>

<internal name="daolama_vault_withdraw">
withdraw#7bdd97de jetton_amount:Coins user_address:MsgAddress = InternalMsgBody;
</internal>

<get_method name="get_pool_data">
<output version="daolama" fixed_length="true">
<int name="halted">bool</int>
<int name="balance">uint64</int>
<int name="borrowed">uint64</int>
<int name="lp_token_balance">uint64</int>
<int name="fee_collected">uint64</int>
</output>
</get_method>
</abi>
Loading