Skip to content

Commit

Permalink
update idl codegen kamino release 0.55 (#437)
Browse files Browse the repository at this point in the history
* update codegen

* update codegen and idl
  • Loading branch information
silviutroscot authored Dec 6, 2023
1 parent 8e67b8b commit 718bb60
Show file tree
Hide file tree
Showing 13 changed files with 805 additions and 30 deletions.
183 changes: 171 additions & 12 deletions packages/hubble-idl/src/kamino.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,38 @@
}
]
},
{
"name": "insertCollateralInfo",
"accounts": [
{
"name": "adminAuthority",
"isMut": true,
"isSigner": true
},
{
"name": "globalConfig",
"isMut": false,
"isSigner": false
},
{
"name": "tokenInfos",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "index",
"type": "u64"
},
{
"name": "params",
"type": {
"defined": "CollateralInfoParams"
}
}
]
},
{
"name": "initializeSharesMetadata",
"accounts": [
Expand Down Expand Up @@ -1957,6 +1989,11 @@
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "instructionSysvarAccount",
"isMut": false,
"isSigner": false
}
],
"args": [
Expand Down Expand Up @@ -2641,20 +2678,10 @@
"isMut": false,
"isSigner": false
},
{
"name": "globalConfig",
"isMut": false,
"isSigner": false
},
{
"name": "newPool",
"isMut": false,
"isSigner": false
},
{
"name": "poolProgram",
"isMut": false,
"isSigner": false
}
],
"args": []
Expand Down Expand Up @@ -3815,6 +3842,12 @@
"name": "farm",
"type": "publicKey"
},
{
"name": "rebalancesCap",
"type": {
"defined": "WithdrawalCaps"
}
},
{
"name": "padding3",
"type": "u64"
Expand All @@ -3824,7 +3857,7 @@
"type": {
"array": [
"u128",
23
21
]
}
},
Expand Down Expand Up @@ -3957,12 +3990,16 @@
"name": "minReferencePriceSlippageToleranceBps",
"type": "u64"
},
{
"name": "actionsAfterRebalanceDelaySeconds",
"type": "u64"
},
{
"name": "padding",
"type": {
"array": [
"u64",
2040
2039
]
}
}
Expand Down Expand Up @@ -4303,6 +4340,86 @@
]
}
},
{
"name": "CollateralInfoParams",
"type": {
"kind": "struct",
"fields": [
{
"name": "mint",
"type": "publicKey"
},
{
"name": "lowerHeuristic",
"type": "u64"
},
{
"name": "upperHeuristic",
"type": "u64"
},
{
"name": "expHeuristic",
"type": "u64"
},
{
"name": "maxTwapDivergenceBps",
"type": "u64"
},
{
"name": "scopeTwapPriceChain",
"type": {
"array": [
"u16",
4
]
}
},
{
"name": "scopePriceChain",
"type": {
"array": [
"u16",
4
]
}
},
{
"name": "name",
"type": {
"array": [
"u8",
32
]
}
},
{
"name": "maxAgePriceSeconds",
"type": "u64"
},
{
"name": "maxAgeTwapSeconds",
"type": "u64"
},
{
"name": "maxIgnorableAmountAsReward",
"type": "u64"
},
{
"name": "disabled",
"type": "u8"
},
{
"name": "scopeStakingRateChain",
"type": {
"array": [
"u16",
4
]
}
}
]
}
},
{
"name": "KaminoRewardInfo",
"type": {
Expand Down Expand Up @@ -4774,6 +4891,9 @@
},
{
"name": "MinReferencePriceSlippageToleranceBps"
},
{
"name": "ActionsAfterRebalanceDelaySeconds"
}
]
}
Expand Down Expand Up @@ -4923,6 +5043,15 @@
},
{
"name": "UpdateFarm"
},
{
"name": "UpdateRebalancesCapCapacity"
},
{
"name": "UpdateRebalancesCapInterval"
},
{
"name": "UpdateRebalancesCapCurrentTotal"
}
]
}
Expand Down Expand Up @@ -6257,6 +6386,36 @@
"code": 6134,
"name": "DriftingOppositeDirection",
"msg": "Drifting strategy is moving in the opposite direction"
},
{
"code": 6135,
"name": "WrongRewardCollateralId",
"msg": "Wrong reward collateral_id"
},
{
"code": 6136,
"name": "CollateralInfoAlreadyExists",
"msg": "Collateral info already exists for given index"
},
{
"code": 6137,
"name": "InvestTooEarly",
"msg": "Invest is too early after the position was opened"
},
{
"code": 6138,
"name": "SwapUnevenTooEarly",
"msg": "Swap uneven is too early after the position was opened"
},
{
"code": 6139,
"name": "FlashSwapTooEarly",
"msg": "Flash swap is too early after the position was opened"
},
{
"code": 6140,
"name": "RebalancesCapReached",
"msg": "Rebalance caps reached, no rebalances are allowed until the end of the current interval"
}
]
}
14 changes: 13 additions & 1 deletion packages/kamino-sdk/src/kamino-client/accounts/GlobalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface GlobalConfigFields {
minPerformanceFeeBps: BN
minSwapUnevenSlippageToleranceBps: BN
minReferencePriceSlippageToleranceBps: BN
actionsAfterRebalanceDelaySeconds: BN
padding: Array<BN>
}

Expand All @@ -51,6 +52,7 @@ export interface GlobalConfigJSON {
minPerformanceFeeBps: string
minSwapUnevenSlippageToleranceBps: string
minReferencePriceSlippageToleranceBps: string
actionsAfterRebalanceDelaySeconds: string
padding: Array<string>
}

Expand All @@ -76,6 +78,7 @@ export class GlobalConfig {
readonly minPerformanceFeeBps: BN
readonly minSwapUnevenSlippageToleranceBps: BN
readonly minReferencePriceSlippageToleranceBps: BN
readonly actionsAfterRebalanceDelaySeconds: BN
readonly padding: Array<BN>

static readonly discriminator = Buffer.from([
Expand Down Expand Up @@ -104,7 +107,8 @@ export class GlobalConfig {
borsh.u64("minPerformanceFeeBps"),
borsh.u64("minSwapUnevenSlippageToleranceBps"),
borsh.u64("minReferencePriceSlippageToleranceBps"),
borsh.array(borsh.u64(), 2040, "padding"),
borsh.u64("actionsAfterRebalanceDelaySeconds"),
borsh.array(borsh.u64(), 2039, "padding"),
])

constructor(fields: GlobalConfigFields) {
Expand All @@ -131,6 +135,8 @@ export class GlobalConfig {
fields.minSwapUnevenSlippageToleranceBps
this.minReferencePriceSlippageToleranceBps =
fields.minReferencePriceSlippageToleranceBps
this.actionsAfterRebalanceDelaySeconds =
fields.actionsAfterRebalanceDelaySeconds
this.padding = fields.padding
}

Expand Down Expand Up @@ -198,6 +204,7 @@ export class GlobalConfig {
minSwapUnevenSlippageToleranceBps: dec.minSwapUnevenSlippageToleranceBps,
minReferencePriceSlippageToleranceBps:
dec.minReferencePriceSlippageToleranceBps,
actionsAfterRebalanceDelaySeconds: dec.actionsAfterRebalanceDelaySeconds,
padding: dec.padding,
})
}
Expand Down Expand Up @@ -229,6 +236,8 @@ export class GlobalConfig {
this.minSwapUnevenSlippageToleranceBps.toString(),
minReferencePriceSlippageToleranceBps:
this.minReferencePriceSlippageToleranceBps.toString(),
actionsAfterRebalanceDelaySeconds:
this.actionsAfterRebalanceDelaySeconds.toString(),
padding: this.padding.map((item) => item.toString()),
}
}
Expand Down Expand Up @@ -264,6 +273,9 @@ export class GlobalConfig {
minReferencePriceSlippageToleranceBps: new BN(
obj.minReferencePriceSlippageToleranceBps
),
actionsAfterRebalanceDelaySeconds: new BN(
obj.actionsAfterRebalanceDelaySeconds
),
padding: obj.padding.map((item) => new BN(item)),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface WhirlpoolStrategyFields {
strategyLookupTable: PublicKey
lastSwapUnevenStepTimestamp: BN
farm: PublicKey
rebalancesCap: types.WithdrawalCapsFields
padding3: BN
padding4: Array<BN>
padding5: Array<BN>
Expand Down Expand Up @@ -199,6 +200,7 @@ export interface WhirlpoolStrategyJSON {
strategyLookupTable: string
lastSwapUnevenStepTimestamp: string
farm: string
rebalancesCap: types.WithdrawalCapsJSON
padding3: string
padding4: Array<string>
padding5: Array<string>
Expand Down Expand Up @@ -300,6 +302,7 @@ export class WhirlpoolStrategy {
readonly strategyLookupTable: PublicKey
readonly lastSwapUnevenStepTimestamp: BN
readonly farm: PublicKey
readonly rebalancesCap: types.WithdrawalCaps
readonly padding3: BN
readonly padding4: Array<BN>
readonly padding5: Array<BN>
Expand Down Expand Up @@ -403,8 +406,9 @@ export class WhirlpoolStrategy {
borsh.publicKey("strategyLookupTable"),
borsh.u64("lastSwapUnevenStepTimestamp"),
borsh.publicKey("farm"),
types.WithdrawalCaps.layout("rebalancesCap"),
borsh.u64("padding3"),
borsh.array(borsh.u128(), 23, "padding4"),
borsh.array(borsh.u128(), 21, "padding4"),
borsh.array(borsh.u128(), 32, "padding5"),
borsh.array(borsh.u128(), 32, "padding6"),
borsh.array(borsh.u128(), 32, "padding7"),
Expand Down Expand Up @@ -514,6 +518,7 @@ export class WhirlpoolStrategy {
this.strategyLookupTable = fields.strategyLookupTable
this.lastSwapUnevenStepTimestamp = fields.lastSwapUnevenStepTimestamp
this.farm = fields.farm
this.rebalancesCap = new types.WithdrawalCaps({ ...fields.rebalancesCap })
this.padding3 = fields.padding3
this.padding4 = fields.padding4
this.padding5 = fields.padding5
Expand Down Expand Up @@ -662,6 +667,7 @@ export class WhirlpoolStrategy {
strategyLookupTable: dec.strategyLookupTable,
lastSwapUnevenStepTimestamp: dec.lastSwapUnevenStepTimestamp,
farm: dec.farm,
rebalancesCap: types.WithdrawalCaps.fromDecoded(dec.rebalancesCap),
padding3: dec.padding3,
padding4: dec.padding4,
padding5: dec.padding5,
Expand Down Expand Up @@ -769,6 +775,7 @@ export class WhirlpoolStrategy {
strategyLookupTable: this.strategyLookupTable.toString(),
lastSwapUnevenStepTimestamp: this.lastSwapUnevenStepTimestamp.toString(),
farm: this.farm.toString(),
rebalancesCap: this.rebalancesCap.toJSON(),
padding3: this.padding3.toString(),
padding4: this.padding4.map((item) => item.toString()),
padding5: this.padding5.map((item) => item.toString()),
Expand Down Expand Up @@ -882,6 +889,7 @@ export class WhirlpoolStrategy {
strategyLookupTable: new PublicKey(obj.strategyLookupTable),
lastSwapUnevenStepTimestamp: new BN(obj.lastSwapUnevenStepTimestamp),
farm: new PublicKey(obj.farm),
rebalancesCap: types.WithdrawalCaps.fromJSON(obj.rebalancesCap),
padding3: new BN(obj.padding3),
padding4: obj.padding4.map((item) => new BN(item)),
padding5: obj.padding5.map((item) => new BN(item)),
Expand Down
Loading

0 comments on commit 718bb60

Please sign in to comment.