/
transfer.go
41 lines (36 loc) · 1.11 KB
/
transfer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package types
import (
"math/big"
"github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types"
)
// GetSenderSubaccountUpdate returns the sender subaccount update
// for this transfer. Currently only supports quote balance update.
func (t *Transfer) GetSenderSubaccountUpdate() (update types.Update) {
return types.Update{
SubaccountId: t.Sender,
AssetUpdates: []types.AssetUpdate{
{
AssetId: t.AssetId,
BigQuantumsDelta: new(big.Int).Neg(t.GetBigQuantums()),
},
},
}
}
// GetRecipientSubaccountUpdate returns the recipient subaccount update
// for this transfer. Currently only supports quote balance update.
func (t *Transfer) GetRecipientSubaccountUpdate() (update types.Update) {
return types.Update{
SubaccountId: t.Recipient,
AssetUpdates: []types.AssetUpdate{
{
AssetId: t.AssetId,
BigQuantumsDelta: t.GetBigQuantums(),
},
},
}
}
// GetBigQuantums returns the amount of the transfer in big notional.
// Currently only supports quote balance update.
func (t *Transfer) GetBigQuantums() (bigNotional *big.Int) {
return new(big.Int).SetUint64(t.Amount)
}