Copy const dca = new Aftermath ( "MAINNET" ) .Dca ();\
Copy const allOrders = await dca .getActiveDcaOrders ({
walletAddress : "0x.." ,
});
Copy {
"active" : [
{
"objectId" : "0x.." ,
"overview" : [
// ..
] ,
"failed" : [
// ..
] ,
"trades" : [
// ..
]
}
] ,
"past" : [
// ..
]
}
Copy const activeOrders = await dca .getActiveDcaOrders ({
walletAddress : "0x.." ,
});
const pastOrders = await dca .getPastDcaOrders ({
walletAddress : "0x.." ,
});
Copy {
"activeOrders" : [
{
"objectId" : "0x.." ,
"overview" : {
"allocatedCoin" : {
"coin" : "0x.." ,
"amount" : "1_000_000n"
} ,
"buyCoin" : {
"coin" : "0x.." ,
"amount" : "1_000_000n"
} ,
"totalSpent" : "1_000_000n" ,
"intervalMs" : 60000 ,
"totalTrades" : 2 ,
"tradesRemaining" : 1 ,
"maxSlippageBps" : 10000 ,
"progress" : 0.5 ,
"recipient" : "0x.." ,
"created" : {
"time" : "1721129837764" ,
"tnxDigest" : "AZLn7s4X..."
} ,
"nextTrade" : {
"time" : 1721129777764 ,
"tnxDigest" : "AZLn7s4X..."
}
} ,
"failed" : [
{
"timestamp" : 1721129777764 ,
"reason" : "INTERNAL"
}
] ,
"trades" : [
{
"allocatedCoin" : {
"coin" : "0x.." ,
"amount" : "1_000_000n"
} ,
"buyCoin" : {
"coin" : "0x.." ,
"amount" : "1_000_000n"
} ,
"tnxDigest" : "AZLn7s4X..." ,
"tnxDate" : "1731751113062" ,
"rate" : 0.00490028
}
]
}
]
}
Copy const tx = dca .getCreateDcaOrderTx ({
walletAddress : "0x.." ,
allocateCoinType : "0x2::sui::SUI" ,
allocateCoinAmount : BigInt ( 10_000_000_000 ) , // 10 SUI
buyCoinType : "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN" ,
frequencyMs : 60000 ,
tradesAmount : 5 ,
delayTimeMs : 0 ,
maxAllowableSlippageBps : 100 ,
coinPerTradeAmount : BigInt ( 2_000_000_000 ) , // 2 SUI
customRecipient : "0x.." ,
strategy : {
minPrice : BigInt ( 4_000_000 ) , // 1SUI ~ 2.0
maxPrice : BigInt ( 8_000_000 ) , // 1SUI ~ 4.0
} ,
});
Copy const signedMessage = dca .closeDcaOrderMessageToSign ({
action : "CANCEL_DCA_ORDER" ,
order_object_id : "0x.."
});
const success = await dca .closeDcaOrder ({
... signedMessage ,
walletAddress : "0x.." ,
});